aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/check-params/services.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/tests/api/check-params/services.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/tests/api/check-params/services.ts')
-rw-r--r--server/tests/api/check-params/services.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/server/tests/api/check-params/services.ts b/server/tests/api/check-params/services.ts
index e57edd9e4..514e3da70 100644
--- a/server/tests/api/check-params/services.ts
+++ b/server/tests/api/check-params/services.ts
@@ -13,6 +13,7 @@ import {
13 setDefaultVideoChannel 13 setDefaultVideoChannel
14} from '../../../../shared/extra-utils' 14} from '../../../../shared/extra-utils'
15import { VideoPlaylistPrivacy } from '@shared/models' 15import { VideoPlaylistPrivacy } from '@shared/models'
16import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
16 17
17describe('Test services API validators', function () { 18describe('Test services API validators', function () {
18 let server: ServerInfo 19 let server: ServerInfo
@@ -66,7 +67,7 @@ describe('Test services API validators', function () {
66 67
67 it('Should fail with an unknown element', async function () { 68 it('Should fail with an unknown element', async function () {
68 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c` 69 const embedUrl = `http://localhost:${server.port}/videos/watch/88fc0165-d1f0-4a35-a51a-3b47f668689c`
69 await checkParamEmbed(server, embedUrl, 404) 70 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_FOUND_404)
70 }) 71 })
71 72
72 it('Should fail with an invalid path', async function () { 73 it('Should fail with an invalid path', async function () {
@@ -78,25 +79,25 @@ describe('Test services API validators', function () {
78 it('Should fail with an invalid max height', async function () { 79 it('Should fail with an invalid max height', async function () {
79 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 80 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
80 81
81 await checkParamEmbed(server, embedUrl, 400, { maxheight: 'hello' }) 82 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxheight: 'hello' })
82 }) 83 })
83 84
84 it('Should fail with an invalid max width', async function () { 85 it('Should fail with an invalid max width', async function () {
85 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 86 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
86 87
87 await checkParamEmbed(server, embedUrl, 400, { maxwidth: 'hello' }) 88 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { maxwidth: 'hello' })
88 }) 89 })
89 90
90 it('Should fail with an invalid format', async function () { 91 it('Should fail with an invalid format', async function () {
91 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 92 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
92 93
93 await checkParamEmbed(server, embedUrl, 400, { format: 'blabla' }) 94 await checkParamEmbed(server, embedUrl, HttpStatusCode.BAD_REQUEST_400, { format: 'blabla' })
94 }) 95 })
95 96
96 it('Should fail with a non supported format', async function () { 97 it('Should fail with a non supported format', async function () {
97 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}` 98 const embedUrl = `http://localhost:${server.port}/videos/watch/${server.video.uuid}`
98 99
99 await checkParamEmbed(server, embedUrl, 501, { format: 'xml' }) 100 await checkParamEmbed(server, embedUrl, HttpStatusCode.NOT_IMPLEMENTED_501, { format: 'xml' })
100 }) 101 })
101 102
102 it('Should succeed with the correct params with a video', async function () { 103 it('Should succeed with the correct params with a video', async function () {
@@ -107,7 +108,7 @@ describe('Test services API validators', function () {
107 maxwidth: 400 108 maxwidth: 400
108 } 109 }
109 110
110 await checkParamEmbed(server, embedUrl, 200, query) 111 await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200, query)
111 }) 112 })
112 113
113 it('Should succeed with the correct params with a playlist', async function () { 114 it('Should succeed with the correct params with a playlist', async function () {
@@ -118,7 +119,7 @@ describe('Test services API validators', function () {
118 maxwidth: 400 119 maxwidth: 400
119 } 120 }
120 121
121 await checkParamEmbed(server, embedUrl, 200, query) 122 await checkParamEmbed(server, embedUrl, HttpStatusCode.OK_200, query)
122 }) 123 })
123 }) 124 })
124 125
@@ -127,7 +128,7 @@ describe('Test services API validators', function () {
127 }) 128 })
128}) 129})
129 130
130function checkParamEmbed (server: ServerInfo, embedUrl: string, statusCodeExpected = 400, query = {}) { 131function checkParamEmbed (server: ServerInfo, embedUrl: string, statusCodeExpected = HttpStatusCode.BAD_REQUEST_400, query = {}) {
131 const path = '/services/oembed' 132 const path = '/services/oembed'
132 133
133 return makeGetRequest({ 134 return makeGetRequest({