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