]>
Commit | Line | Data |
---|---|---|
3521ab8f C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
4 | import * as chai from 'chai' | |
4c7e60bc | 5 | import { cleanupTests, createSingleServer, PeerTubeServer, SearchCommand, setAccessTokensToServers } from '@shared/extra-utils' |
3521ab8f C |
6 | import { VideoChannel } from '@shared/models' |
7 | ||
8 | const expect = chai.expect | |
9 | ||
10 | describe('Test channels search', function () { | |
254d3579 | 11 | let server: PeerTubeServer = null |
af971e06 | 12 | let command: SearchCommand |
3521ab8f C |
13 | |
14 | before(async function () { | |
15 | this.timeout(30000) | |
16 | ||
254d3579 | 17 | server = await createSingleServer(1) |
3521ab8f C |
18 | |
19 | await setAccessTokensToServers([ server ]) | |
20 | ||
21 | { | |
89d241a7 | 22 | await server.users.create({ username: 'user1', password: 'password' }) |
3521ab8f C |
23 | const channel = { |
24 | name: 'squall_channel', | |
25 | displayName: 'Squall channel' | |
26 | } | |
89d241a7 | 27 | await server.channels.create({ attributes: channel }) |
3521ab8f | 28 | } |
af971e06 | 29 | |
89d241a7 | 30 | command = server.search |
3521ab8f C |
31 | }) |
32 | ||
33 | it('Should make a simple search and not have results', async function () { | |
af971e06 | 34 | const body = await command.searchChannels({ search: 'abc' }) |
3521ab8f | 35 | |
af971e06 C |
36 | expect(body.total).to.equal(0) |
37 | expect(body.data).to.have.lengthOf(0) | |
3521ab8f C |
38 | }) |
39 | ||
40 | it('Should make a search and have results', async function () { | |
41 | { | |
42 | const search = { | |
43 | search: 'Squall', | |
44 | start: 0, | |
45 | count: 1 | |
46 | } | |
af971e06 C |
47 | const body = await command.advancedChannelSearch({ search }) |
48 | expect(body.total).to.equal(1) | |
49 | expect(body.data).to.have.lengthOf(1) | |
3521ab8f | 50 | |
af971e06 | 51 | const channel: VideoChannel = body.data[0] |
3521ab8f C |
52 | expect(channel.name).to.equal('squall_channel') |
53 | expect(channel.displayName).to.equal('Squall channel') | |
54 | } | |
55 | ||
56 | { | |
57 | const search = { | |
58 | search: 'Squall', | |
59 | start: 1, | |
60 | count: 1 | |
61 | } | |
62 | ||
af971e06 C |
63 | const body = await command.advancedChannelSearch({ search }) |
64 | expect(body.total).to.equal(1) | |
65 | expect(body.data).to.have.lengthOf(0) | |
3521ab8f C |
66 | } |
67 | }) | |
68 | ||
69 | after(async function () { | |
70 | await cleanupTests([ server ]) | |
71 | }) | |
72 | }) |