http-status-codes.test.ts 759 B

12345678910111213141516171819202122232425
  1. import { describe, expect, it } from 'vitest'
  2. import { getHttpStatusCodeInfo } from './http-status-codes'
  3. describe('getHttpStatusCodeInfo', () => {
  4. it('should return the correct status code info', () => {
  5. const statusCodeInfo = getHttpStatusCodeInfo(400)
  6. expect(statusCodeInfo).toEqual({
  7. code: 400,
  8. name: 'BAD_REQUEST',
  9. message: 'The server cannot or will not process the request due to an apparent client error.',
  10. label: 'Bad Request',
  11. })
  12. })
  13. it('should return unknown for an unknown status code', () => {
  14. const statusCodeInfo = getHttpStatusCodeInfo(999)
  15. expect(statusCodeInfo).toEqual({
  16. code: 999,
  17. name: 'UNKNOWN',
  18. message: 'Unknown status code',
  19. label: 'Unknown',
  20. })
  21. })
  22. })