diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /shared/extra-utils/search | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip |
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'shared/extra-utils/search')
-rw-r--r-- | shared/extra-utils/search/video-channels.ts | 5 | ||||
-rw-r--r-- | shared/extra-utils/search/videos.ts | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/shared/extra-utils/search/video-channels.ts b/shared/extra-utils/search/video-channels.ts index d16210530..8e0f42578 100644 --- a/shared/extra-utils/search/video-channels.ts +++ b/shared/extra-utils/search/video-channels.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | import { VideoChannelsSearchQuery } from '@shared/models' | 1 | import { VideoChannelsSearchQuery } from '@shared/models' |
2 | import { makeGetRequest } from '../requests/requests' | 2 | import { makeGetRequest } from '../requests/requests' |
3 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
3 | 4 | ||
4 | function searchVideoChannel (url: string, search: string, token?: string, statusCodeExpected = 200) { | 5 | function searchVideoChannel (url: string, search: string, token?: string, statusCodeExpected = HttpStatusCode.OK_200) { |
5 | const path = '/api/v1/search/video-channels' | 6 | const path = '/api/v1/search/video-channels' |
6 | 7 | ||
7 | return makeGetRequest({ | 8 | return makeGetRequest({ |
@@ -23,7 +24,7 @@ function advancedVideoChannelSearch (url: string, search: VideoChannelsSearchQue | |||
23 | url, | 24 | url, |
24 | path, | 25 | path, |
25 | query: search, | 26 | query: search, |
26 | statusCodeExpected: 200 | 27 | statusCodeExpected: HttpStatusCode.OK_200 |
27 | }) | 28 | }) |
28 | } | 29 | } |
29 | 30 | ||
diff --git a/shared/extra-utils/search/videos.ts b/shared/extra-utils/search/videos.ts index 4c52ea11c..ac65357e3 100644 --- a/shared/extra-utils/search/videos.ts +++ b/shared/extra-utils/search/videos.ts | |||
@@ -3,6 +3,7 @@ | |||
3 | import * as request from 'supertest' | 3 | import * as request from 'supertest' |
4 | import { VideosSearchQuery } from '../../models/search' | 4 | import { VideosSearchQuery } from '../../models/search' |
5 | import { immutableAssign } from '../miscs/miscs' | 5 | import { immutableAssign } from '../miscs/miscs' |
6 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
6 | 7 | ||
7 | function searchVideo (url: string, search: string) { | 8 | function searchVideo (url: string, search: string) { |
8 | const path = '/api/v1/search/videos' | 9 | const path = '/api/v1/search/videos' |
@@ -13,7 +14,7 @@ function searchVideo (url: string, search: string) { | |||
13 | .query(query) | 14 | .query(query) |
14 | .set('Accept', 'application/json') | 15 | .set('Accept', 'application/json') |
15 | 16 | ||
16 | return req.expect(200) | 17 | return req.expect(HttpStatusCode.OK_200) |
17 | .expect('Content-Type', /json/) | 18 | .expect('Content-Type', /json/) |
18 | } | 19 | } |
19 | 20 | ||
@@ -25,7 +26,7 @@ function searchVideoWithToken (url: string, search: string, token: string, query | |||
25 | .query(immutableAssign(query, { sort: '-publishedAt', search })) | 26 | .query(immutableAssign(query, { sort: '-publishedAt', search })) |
26 | .set('Accept', 'application/json') | 27 | .set('Accept', 'application/json') |
27 | 28 | ||
28 | return req.expect(200) | 29 | return req.expect(HttpStatusCode.OK_200) |
29 | .expect('Content-Type', /json/) | 30 | .expect('Content-Type', /json/) |
30 | } | 31 | } |
31 | 32 | ||
@@ -38,7 +39,7 @@ function searchVideoWithSort (url: string, search: string, sort: string) { | |||
38 | .get(path) | 39 | .get(path) |
39 | .query(query) | 40 | .query(query) |
40 | .set('Accept', 'application/json') | 41 | .set('Accept', 'application/json') |
41 | .expect(200) | 42 | .expect(HttpStatusCode.OK_200) |
42 | .expect('Content-Type', /json/) | 43 | .expect('Content-Type', /json/) |
43 | } | 44 | } |
44 | 45 | ||
@@ -49,7 +50,7 @@ function advancedVideosSearch (url: string, options: VideosSearchQuery) { | |||
49 | .get(path) | 50 | .get(path) |
50 | .query(options) | 51 | .query(options) |
51 | .set('Accept', 'application/json') | 52 | .set('Accept', 'application/json') |
52 | .expect(200) | 53 | .expect(HttpStatusCode.OK_200) |
53 | .expect('Content-Type', /json/) | 54 | .expect('Content-Type', /json/) |
54 | } | 55 | } |
55 | 56 | ||