aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/search/search-channels.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-06 15:22:51 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commitaf971e06c620bd46a5aa64c8833364e7022b5e3d (patch)
tree4288b66b79fe4dd1ab9496e85a3abf7d747ad03a /server/tests/api/search/search-channels.ts
parent23a3a8827cb8b862f5cc7ee2819f39918303beca (diff)
downloadPeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.gz
PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.tar.zst
PeerTube-af971e06c620bd46a5aa64c8833364e7022b5e3d.zip
Introduce search command
Diffstat (limited to 'server/tests/api/search/search-channels.ts')
-rw-r--r--server/tests/api/search/search-channels.ts29
1 files changed, 15 insertions, 14 deletions
diff --git a/server/tests/api/search/search-channels.ts b/server/tests/api/search/search-channels.ts
index daca2aebe..307bc063d 100644
--- a/server/tests/api/search/search-channels.ts
+++ b/server/tests/api/search/search-channels.ts
@@ -2,21 +2,22 @@
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'
6import { 5import {
7 addVideoChannel, 6 addVideoChannel,
8 cleanupTests, 7 cleanupTests,
9 createUser, 8 createUser,
10 flushAndRunServer, 9 flushAndRunServer,
10 SearchCommand,
11 ServerInfo, 11 ServerInfo,
12 setAccessTokensToServers 12 setAccessTokensToServers
13} from '../../../../shared/extra-utils' 13} from '@shared/extra-utils'
14import { VideoChannel } from '@shared/models' 14import { VideoChannel } from '@shared/models'
15 15
16const expect = chai.expect 16const expect = chai.expect
17 17
18describe('Test channels search', function () { 18describe('Test channels search', function () {
19 let server: ServerInfo = null 19 let server: ServerInfo = null
20 let command: SearchCommand
20 21
21 before(async function () { 22 before(async function () {
22 this.timeout(30000) 23 this.timeout(30000)
@@ -33,13 +34,15 @@ describe('Test channels search', function () {
33 } 34 }
34 await addVideoChannel(server.url, server.accessToken, channel) 35 await addVideoChannel(server.url, server.accessToken, channel)
35 } 36 }
37
38 command = server.searchCommand
36 }) 39 })
37 40
38 it('Should make a simple search and not have results', async function () { 41 it('Should make a simple search and not have results', async function () {
39 const res = await searchVideoChannel(server.url, 'abc') 42 const body = await command.searchChannels({ search: 'abc' })
40 43
41 expect(res.body.total).to.equal(0) 44 expect(body.total).to.equal(0)
42 expect(res.body.data).to.have.lengthOf(0) 45 expect(body.data).to.have.lengthOf(0)
43 }) 46 })
44 47
45 it('Should make a search and have results', async function () { 48 it('Should make a search and have results', async function () {
@@ -49,11 +52,11 @@ describe('Test channels search', function () {
49 start: 0, 52 start: 0,
50 count: 1 53 count: 1
51 } 54 }
52 const res = await advancedVideoChannelSearch(server.url, search) 55 const body = await command.advancedChannelSearch({ search })
53 expect(res.body.total).to.equal(1) 56 expect(body.total).to.equal(1)
54 expect(res.body.data).to.have.lengthOf(1) 57 expect(body.data).to.have.lengthOf(1)
55 58
56 const channel: VideoChannel = res.body.data[0] 59 const channel: VideoChannel = body.data[0]
57 expect(channel.name).to.equal('squall_channel') 60 expect(channel.name).to.equal('squall_channel')
58 expect(channel.displayName).to.equal('Squall channel') 61 expect(channel.displayName).to.equal('Squall channel')
59 } 62 }
@@ -65,11 +68,9 @@ describe('Test channels search', function () {
65 count: 1 68 count: 1
66 } 69 }
67 70
68 const res = await advancedVideoChannelSearch(server.url, search) 71 const body = await command.advancedChannelSearch({ search })
69 72 expect(body.total).to.equal(1)
70 expect(res.body.total).to.equal(1) 73 expect(body.data).to.have.lengthOf(0)
71
72 expect(res.body.data).to.have.lengthOf(0)
73 } 74 }
74 }) 75 })
75 76