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