1 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
4 import * as chai from 'chai'
5 import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils'
6 import { VideoChannel } from '@shared/models'
8 const expect = chai.expect
10 describe('Test channels search', function () {
11 let server: PeerTubeServer = null
12 let command: SearchCommand
14 before(async function () {
17 server = await createSingleServer(1)
19 await setAccessTokensToServers([ server ])
22 await server.users.create({ username: 'user1', password: 'password' })
24 name: 'squall_channel',
25 displayName: 'Squall channel'
27 await server.channels.create({ attributes: channel })
30 command = server.search
33 it('Should make a simple search and not have results', async function () {
34 const body = await command.searchChannels({ search: 'abc' })
36 expect(body.total).to.equal(0)
37 expect(body.data).to.have.lengthOf(0)
40 it('Should make a search and have results', async function () {
47 const body = await command.advancedChannelSearch({ search })
48 expect(body.total).to.equal(1)
49 expect(body.data).to.have.lengthOf(1)
51 const channel: VideoChannel = body.data[0]
52 expect(channel.name).to.equal('squall_channel')
53 expect(channel.displayName).to.equal('Squall channel')
63 const body = await command.advancedChannelSearch({ search })
64 expect(body.total).to.equal(1)
65 expect(body.data).to.have.lengthOf(0)
69 after(async function () {
70 await cleanupTests([ server ])