diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-09 11:21:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-09 11:24:15 +0200 |
commit | 22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b (patch) | |
tree | ad8668b1480997f5e48cd5188630265aa21dfeba /server/tests/api/users/users.ts | |
parent | c100a6142e6571312db9f6407698a21a08b593fb (diff) | |
download | PeerTube-22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b.tar.gz PeerTube-22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b.tar.zst PeerTube-22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b.zip |
Add check params account ratings tests
Diffstat (limited to 'server/tests/api/users/users.ts')
-rw-r--r-- | server/tests/api/users/users.ts | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index bc069a7be..6e7de9c38 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -140,31 +140,27 @@ describe('Test users', function () { | |||
140 | 140 | ||
141 | it('Should retrieve ratings list', async function () { | 141 | it('Should retrieve ratings list', async function () { |
142 | await rateVideo(server.url, accessToken, videoId, 'like') | 142 | await rateVideo(server.url, accessToken, videoId, 'like') |
143 | const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200) | 143 | |
144 | const res = await getAccountRatings(server.url, server.user.username, server.accessToken, null, 200) | ||
144 | const ratings = res.body | 145 | const ratings = res.body |
145 | 146 | ||
147 | expect(ratings.total).to.equal(1) | ||
146 | expect(ratings.data[0].video.id).to.equal(videoId) | 148 | expect(ratings.data[0].video.id).to.equal(videoId) |
147 | expect(ratings.data[0].rating).to.equal('like') | 149 | expect(ratings.data[0].rating).to.equal('like') |
148 | }) | 150 | }) |
149 | 151 | ||
150 | it('Should retrieve ratings list by rating type', async function () { | 152 | it('Should retrieve ratings list by rating type', async function () { |
151 | await rateVideo(server.url, accessToken, videoId, 'like') | 153 | { |
152 | let res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200, { rating: 'like' }) | 154 | const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'like') |
153 | let ratings = res.body | 155 | const ratings = res.body |
154 | expect(ratings.data.length).to.equal(1) | 156 | expect(ratings.data.length).to.equal(1) |
155 | res = await getAccountRatings(server.url, server.user.username, server.accessToken, 200, { rating: 'dislike' }) | 157 | } |
156 | ratings = res.body | 158 | |
157 | expect(ratings.data.length).to.equal(0) | 159 | { |
158 | await getAccountRatings(server.url, server.user.username, server.accessToken, 400, { rating: 'invalid' }) | 160 | const res = await getAccountRatings(server.url, server.user.username, server.accessToken, 'dislike') |
159 | }) | 161 | const ratings = res.body |
160 | 162 | expect(ratings.data.length).to.equal(0) | |
161 | it('Should not access ratings list if not logged with correct user', async function () { | 163 | } |
162 | const user = { username: 'anuragh', password: 'passbyme' } | ||
163 | const resUser = await createUser(server.url, server.accessToken, user.username, user.password) | ||
164 | const userId = resUser.body.user.id | ||
165 | const userAccessToken = await userLogin(server, user) | ||
166 | await getAccountRatings(server.url, server.user.username, userAccessToken, 403) | ||
167 | await removeUser(server.url, userId, server.accessToken) | ||
168 | }) | 164 | }) |
169 | 165 | ||
170 | it('Should not be able to remove the video with an incorrect token', async function () { | 166 | it('Should not be able to remove the video with an incorrect token', async function () { |