]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/tests/api/search/search-channels.ts
Introduce streaming playlists command
[github/Chocobozzz/PeerTube.git] / server / tests / api / search / search-channels.ts
CommitLineData
3521ab8f
C
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import * as chai from 'chai'
3521ab8f
C
5import {
6 addVideoChannel,
7 cleanupTests,
8 createUser,
9 flushAndRunServer,
af971e06 10 SearchCommand,
3521ab8f
C
11 ServerInfo,
12 setAccessTokensToServers
af971e06 13} from '@shared/extra-utils'
3521ab8f
C
14import { VideoChannel } from '@shared/models'
15
16const expect = chai.expect
17
18describe('Test channels search', function () {
19 let server: ServerInfo = null
af971e06 20 let command: SearchCommand
3521ab8f
C
21
22 before(async function () {
23 this.timeout(30000)
24
25 server = await flushAndRunServer(1)
26
27 await setAccessTokensToServers([ server ])
28
29 {
30 await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' })
31 const channel = {
32 name: 'squall_channel',
33 displayName: 'Squall channel'
34 }
35 await addVideoChannel(server.url, server.accessToken, channel)
36 }
af971e06
C
37
38 command = server.searchCommand
3521ab8f
C
39 })
40
41 it('Should make a simple search and not have results', async function () {
af971e06 42 const body = await command.searchChannels({ search: 'abc' })
3521ab8f 43
af971e06
C
44 expect(body.total).to.equal(0)
45 expect(body.data).to.have.lengthOf(0)
3521ab8f
C
46 })
47
48 it('Should make a search and have results', async function () {
49 {
50 const search = {
51 search: 'Squall',
52 start: 0,
53 count: 1
54 }
af971e06
C
55 const body = await command.advancedChannelSearch({ search })
56 expect(body.total).to.equal(1)
57 expect(body.data).to.have.lengthOf(1)
3521ab8f 58
af971e06 59 const channel: VideoChannel = body.data[0]
3521ab8f
C
60 expect(channel.name).to.equal('squall_channel')
61 expect(channel.displayName).to.equal('Squall channel')
62 }
63
64 {
65 const search = {
66 search: 'Squall',
67 start: 1,
68 count: 1
69 }
70
af971e06
C
71 const body = await command.advancedChannelSearch({ search })
72 expect(body.total).to.equal(1)
73 expect(body.data).to.have.lengthOf(0)
3521ab8f
C
74 }
75 })
76
77 after(async function () {
78 await cleanupTests([ server ])
79 })
80})