2
1

check-api-params.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { makeGetRequest } from './requests'
  2. import { immutableAssign } from '../miscs/miscs'
  3. import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
  4. function checkBadStartPagination (url: string, path: string, token?: string, query = {}) {
  5. return makeGetRequest({
  6. url,
  7. path,
  8. token,
  9. query: immutableAssign(query, { start: 'hello' }),
  10. statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
  11. })
  12. }
  13. async function checkBadCountPagination (url: string, path: string, token?: string, query = {}) {
  14. await makeGetRequest({
  15. url,
  16. path,
  17. token,
  18. query: immutableAssign(query, { count: 'hello' }),
  19. statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
  20. })
  21. await makeGetRequest({
  22. url,
  23. path,
  24. token,
  25. query: immutableAssign(query, { count: 2000 }),
  26. statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
  27. })
  28. }
  29. function checkBadSortPagination (url: string, path: string, token?: string, query = {}) {
  30. return makeGetRequest({
  31. url,
  32. path,
  33. token,
  34. query: immutableAssign(query, { sort: 'hello' }),
  35. statusCodeExpected: HttpStatusCode.BAD_REQUEST_400
  36. })
  37. }
  38. // ---------------------------------------------------------------------------
  39. export {
  40. checkBadStartPagination,
  41. checkBadCountPagination,
  42. checkBadSortPagination
  43. }