Debian Codegraph @

spec/after_test.ts

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 import type Ajv from ".."
2 import type {AnySchema, ErrorObject} from ".."
3 import chai from "./chai"
4 const should = chai.should()
5
6 interface TestResult {
7 validator: Ajv
8 schema: AnySchema
9 data: unknown
10 valid: boolean
11 expected: boolean
12 errors: ErrorObject[] | null
13 passed: boolean // true if valid == expected
14 }
15
16 export function afterError(res: TestResult): void {
17 console.log("ajv options:", res.validator.opts)
18 }
19
20 export function afterEach(res: TestResult): void {
21 // console.log(res.errors);
22 res.valid.should.be.a("boolean")
23 if (res.valid === true) {
24 should.equal(res.errors, null)
25 } else {
26 const errs = res.errors as ErrorObject[]
27 errs.should.be.an("array")
28 for (const err of errs) {
29 err.should.be.an("object")
30 }
31 }
32 }