X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fcheck-params%2Fsearch.ts;h=7b7e07784f96d965f075faa834b86fbb0146c48a;hb=5b9c965d5aa747f29b081289f930ee215fdc23c8;hp=d35eac7fe2498d8c1e93b62366e98ba6ceeb91fa;hpb=d525fc399a14a8b16eaad6d4c0bc0a9c4093c3c9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/check-params/search.ts b/server/tests/api/check-params/search.ts index d35eac7fe..7b7e07784 100644 --- a/server/tests/api/check-params/search.ts +++ b/server/tests/api/check-params/search.ts @@ -2,11 +2,14 @@ import 'mocha' -import { flushTests, immutableAssign, killallServers, makeGetRequest, runServer, ServerInfo } from '../../utils' -import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '../../utils/requests/check-api-params' +import { flushTests, immutableAssign, killallServers, makeGetRequest, runServer, ServerInfo } from '../../../../shared/utils' +import { + checkBadCountPagination, + checkBadSortPagination, + checkBadStartPagination +} from '../../../../shared/utils/requests/check-api-params' describe('Test videos API validator', function () { - const path = '/api/v1/search/videos/' let server: ServerInfo // --------------------------------------------------------------- @@ -20,6 +23,8 @@ describe('Test videos API validator', function () { }) describe('When searching videos', function () { + const path = '/api/v1/search/videos/' + const query = { search: 'coucou' } @@ -108,6 +113,36 @@ describe('Test videos API validator', function () { const customQuery2 = immutableAssign(query, { endDate: 'hello' }) await makeGetRequest({ url: server.url, path, query: customQuery2, statusCodeExpected: 400 }) + + const customQuery3 = immutableAssign(query, { originallyPublishedStartDate: 'hello' }) + await makeGetRequest({ url: server.url, path, query: customQuery3, statusCodeExpected: 400 }) + + const customQuery4 = immutableAssign(query, { originallyPublishedEndDate: 'hello' }) + await makeGetRequest({ url: server.url, path, query: customQuery4, statusCodeExpected: 400 }) + }) + }) + + describe('When searching video channels', function () { + const path = '/api/v1/search/video-channels/' + + const query = { + search: 'coucou' + } + + it('Should fail with a bad start pagination', async function () { + await checkBadStartPagination(server.url, path, null, query) + }) + + it('Should fail with a bad count pagination', async function () { + await checkBadCountPagination(server.url, path, null, query) + }) + + it('Should fail with an incorrect sort', async function () { + await checkBadSortPagination(server.url, path, null, query) + }) + + it('Should success with the correct parameters', async function () { + await makeGetRequest({ url: server.url, path, query, statusCodeExpected: 200 }) }) })