-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.spec.ts
More file actions
36 lines (35 loc) · 1.41 KB
/
errors.spec.ts
File metadata and controls
36 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { validateWithTypeBox } from '@nrfcloud/validate-with-typebox'
import assert from 'node:assert/strict'
import { describe, test } from 'node:test'
import { BadRequestError } from './BadRequestError.ts'
import { ConflictError } from './ConflictError.ts'
import { InternalError } from './InternalError.ts'
import { NotFoundError } from './NotFoundError.ts'
import { ProblemDetail } from './ProblemDetail.ts'
import BAD_REQUEST from './examples/BAD_REQUEST.json' with { type: 'json' }
import CONFLICT_ERROR from './examples/CONFLICT.json' with { type: 'json' }
import INTERNAL_ERROR from './examples/INTERNAL_ERROR.json' with { type: 'json' }
import NOT_FOUND_ERROR from './examples/NOT_FOUND.json' with { type: 'json' }
void describe('Error helpers', () => {
const validator = validateWithTypeBox(ProblemDetail)
void test('BadRequestError', () => {
const e = BadRequestError(BAD_REQUEST)
const result = validator(e)
assert.equal('errors' in result, false)
})
void test('ConflictError', () => {
const e = ConflictError(CONFLICT_ERROR)
const result = validator(e)
assert.equal('errors' in result, false)
})
void test('InternalError', () => {
const e = InternalError(INTERNAL_ERROR)
const result = validator(e)
assert.equal('errors' in result, false)
})
void test('NotFoundError', () => {
const e = NotFoundError(NOT_FOUND_ERROR)
const result = validator(e)
assert.equal('errors' in result, false)
})
})