diff options
Diffstat (limited to 'server/tests/api/search/search-channels.ts')
-rw-r--r-- | server/tests/api/search/search-channels.ts | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts new file mode 100644 index 000000000..daca2aebe --- /dev/null +++ b/server/tests/api/search/search-channels.ts | |||
@@ -0,0 +1,79 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | ||
2 | |||
3 | import 'mocha' | ||
4 | import * as chai from 'chai' | ||
5 | import { searchVideoChannel, advancedVideoChannelSearch } from '@shared/extra-utils/search/video-channels' | ||
6 | import { | ||
7 | addVideoChannel, | ||
8 | cleanupTests, | ||
9 | createUser, | ||
10 | flushAndRunServer, | ||
11 | ServerInfo, | ||
12 | setAccessTokensToServers | ||
13 | } from '../../../../shared/extra-utils' | ||
14 | import { VideoChannel } from '@shared/models' | ||
15 | |||
16 | const expect = chai.expect | ||
17 | |||
18 | describe('Test channels search', function () { | ||
19 | let server: ServerInfo = null | ||
20 | |||
21 | before(async function () { | ||
22 | this.timeout(30000) | ||
23 | |||
24 | server = await flushAndRunServer(1) | ||
25 | |||
26 | await setAccessTokensToServers([ server ]) | ||
27 | |||
28 | { | ||
29 | await createUser({ url: server.url, accessToken: server.accessToken, username: 'user1', password: 'password' }) | ||
30 | const channel = { | ||
31 | name: 'squall_channel', | ||
32 | displayName: 'Squall channel' | ||
33 | } | ||
34 | await addVideoChannel(server.url, server.accessToken, channel) | ||
35 | } | ||
36 | }) | ||
37 | |||
38 | it('Should make a simple search and not have results', async function () { | ||
39 | const res = await searchVideoChannel(server.url, 'abc') | ||
40 | |||
41 | expect(res.body.total).to.equal(0) | ||
42 | expect(res.body.data).to.have.lengthOf(0) | ||
43 | }) | ||
44 | |||
45 | it('Should make a search and have results', async function () { | ||
46 | { | ||
47 | const search = { | ||
48 | search: 'Squall', | ||
49 | start: 0, | ||
50 | count: 1 | ||
51 | } | ||
52 | const res = await advancedVideoChannelSearch(server.url, search) | ||
53 | expect(res.body.total).to.equal(1) | ||
54 | expect(res.body.data).to.have.lengthOf(1) | ||
55 | |||
56 | const channel: VideoChannel = res.body.data[0] | ||
57 | expect(channel.name).to.equal('squall_channel') | ||
58 | expect(channel.displayName).to.equal('Squall channel') | ||
59 | } | ||
60 | |||
61 | { | ||
62 | const search = { | ||
63 | search: 'Squall', | ||
64 | start: 1, | ||
65 | count: 1 | ||
66 | } | ||
67 | |||
68 | const res = await advancedVideoChannelSearch(server.url, search) | ||
69 | |||
70 | expect(res.body.total).to.equal(1) | ||
71 | |||
72 | expect(res.body.data).to.have.lengthOf(0) | ||
73 | } | ||
74 | }) | ||
75 | |||
76 | after(async function () { | ||
77 | await cleanupTests([ server ]) | ||
78 | }) | ||
79 | }) | ||