From 7b3909644dd7cb8be1caad537bb40605e5f059d4 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 27 Jul 2020 17:00:39 +0200 Subject: test search for subscriptions and video-channels --- server/tests/api/users/user-subscriptions.ts | 32 ++++++++++++++++++++++++++-- server/tests/api/videos/video-channels.ts | 26 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) (limited to 'server/tests/api') diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 7d6b0c6a9..60676a37b 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts @@ -96,14 +96,14 @@ describe('Test users subscriptions', function () { it('Should list subscriptions', async function () { { - const res = await listUserSubscriptions(servers[0].url, servers[0].accessToken) + const res = await listUserSubscriptions({ url: servers[0].url, token: servers[0].accessToken }) expect(res.body.total).to.equal(0) expect(res.body.data).to.be.an('array') expect(res.body.data).to.have.lengthOf(0) } { - const res = await listUserSubscriptions(servers[0].url, users[0].accessToken, 'createdAt') + const res = await listUserSubscriptions({ url: servers[0].url, token: users[0].accessToken, sort: 'createdAt' }) expect(res.body.total).to.equal(2) const subscriptions: VideoChannel[] = res.body.data @@ -156,6 +156,34 @@ describe('Test users subscriptions', function () { expect(body['user3_channel@localhost:' + servers[0].port]).to.be.false }) + it('Should search among subscriptions', async function () { + { + const res = await listUserSubscriptions({ + url: servers[0].url, + token: users[0].accessToken, + sort: '-createdAt', + search: 'user3_channel' + }) + expect(res.body.total).to.equal(1) + + const subscriptions = res.body.data + expect(subscriptions).to.have.lengthOf(1) + } + + { + const res = await listUserSubscriptions({ + url: servers[0].url, + token: users[0].accessToken, + sort: '-createdAt', + search: 'toto' + }) + expect(res.body.total).to.equal(0) + + const subscriptions = res.body.data + expect(subscriptions).to.have.lengthOf(0) + } + }) + it('Should list subscription videos', async function () { { const res = await listUserSubscriptionVideos(servers[0].url, servers[0].accessToken) diff --git a/server/tests/api/videos/video-channels.ts b/server/tests/api/videos/video-channels.ts index 3493a723d..367f99fdd 100644 --- a/server/tests/api/videos/video-channels.ts +++ b/server/tests/api/videos/video-channels.ts @@ -421,6 +421,32 @@ describe('Test video channels', function () { expect(totoChannel.videosCount).to.equal(0) }) + it('Should search among account video channels', async function () { + { + const res = await getAccountVideoChannelsList({ + url: servers[0].url, + accountName: userInfo.account.name + '@' + userInfo.account.host, + search: 'root' + }) + expect(res.body.total).to.equal(1) + + const channels = res.body.data + expect(channels).to.have.lengthOf(1) + } + + { + const res = await getAccountVideoChannelsList({ + url: servers[0].url, + accountName: userInfo.account.name + '@' + userInfo.account.host, + search: 'does not exist' + }) + expect(res.body.total).to.equal(0) + + const channels = res.body.data + expect(channels).to.have.lengthOf(0) + } + }) + after(async function () { await cleanupTests(servers) }) -- cgit v1.2.3