1
0
Fork 0
peertube/shared/extra-utils/requests/check-api-params.ts

41 lines
976 B
TypeScript
Raw Normal View History

2017-12-28 08:29:57 -05:00
import { makeGetRequest } from './requests'
2018-11-19 11:08:18 -05:00
import { immutableAssign } from '../miscs/miscs'
2017-12-28 08:29:57 -05:00
2018-07-20 08:35:18 -04:00
function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
2017-12-28 08:29:57 -05:00
return makeGetRequest({
url,
path,
2017-12-28 08:40:11 -05:00
token,
2018-07-20 08:35:18 -04:00
query: immutableAssign(query, { start: 'hello' }),
2017-12-28 08:29:57 -05:00
statusCodeExpected: 400
})
}
2018-07-20 08:35:18 -04:00
function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
2017-12-28 08:29:57 -05:00
return makeGetRequest({
url,
path,
2017-12-28 08:40:11 -05:00
token,
2018-07-20 08:35:18 -04:00
query: immutableAssign(query, { count: 'hello' }),
2017-12-28 08:29:57 -05:00
statusCodeExpected: 400
})
}
2018-07-20 08:35:18 -04:00
function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {
2017-12-28 08:29:57 -05:00
return makeGetRequest({
url,
path,
2017-12-28 08:40:11 -05:00
token,
2018-07-20 08:35:18 -04:00
query: immutableAssign(query, { sort: 'hello' }),
2017-12-28 08:29:57 -05:00
statusCodeExpected: 400
})
}
// ---------------------------------------------------------------------------
export {
checkBadStartPagination,
checkBadCountPagination,
checkBadSortPagination
}