accounts.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
  2. import 'mocha'
  3. import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../../shared/extra-utils'
  4. import {
  5. checkBadCountPagination,
  6. checkBadSortPagination,
  7. checkBadStartPagination
  8. } from '../../../../shared/extra-utils/requests/check-api-params'
  9. import { getAccount } from '../../../../shared/extra-utils/users/accounts'
  10. import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
  11. describe('Test accounts API validators', function () {
  12. const path = '/api/v1/accounts/'
  13. let server: ServerInfo
  14. // ---------------------------------------------------------------
  15. before(async function () {
  16. this.timeout(30000)
  17. server = await flushAndRunServer(1)
  18. })
  19. describe('When listing accounts', function () {
  20. it('Should fail with a bad start pagination', async function () {
  21. await checkBadStartPagination(server.url, path, server.accessToken)
  22. })
  23. it('Should fail with a bad count pagination', async function () {
  24. await checkBadCountPagination(server.url, path, server.accessToken)
  25. })
  26. it('Should fail with an incorrect sort', async function () {
  27. await checkBadSortPagination(server.url, path, server.accessToken)
  28. })
  29. })
  30. describe('When getting an account', function () {
  31. it('Should return 404 with a non existing name', async function () {
  32. await getAccount(server.url, 'arfaze', HttpStatusCode.NOT_FOUND_404)
  33. })
  34. })
  35. after(async function () {
  36. await cleanupTests([ server ])
  37. })
  38. })