Debian Codegraph @

spec/issues/1949_jtd_empty_values.spec.ts

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 import _Ajv from "../ajv_jtd"
2 import * as assert from "assert"
3
4 describe("JTD values with empty schema (issue #1949)", () => {
5 const ajv = new _Ajv()
6
7 it("should correctly validate empty values form", () => {
8 const schema = {values: {}}
9 const validate = ajv.compile(schema)
10 assert.strictEqual(validate({prop1: 1, prop2: 2}), true)
11 assert.strictEqual(validate({}), true)
12 assert.strictEqual(validate(null), false)
13 assert.strictEqual(validate(1), false)
14 assert.strictEqual(validate("foo"), false)
15 assert.strictEqual(validate(undefined), false)
16 })
17
18 it("should correctly validate nullable empty values form", () => {
19 const schema = {values: {}, nullable: true}
20 const validate = ajv.compile(schema)
21 assert.strictEqual(validate({prop1: 1, prop2: 2}), true)
22 assert.strictEqual(validate({}), true)
23 assert.strictEqual(validate(null), true)
24 assert.strictEqual(validate(1), false)
25 assert.strictEqual(validate("foo"), false)
26 assert.strictEqual(validate(undefined), false)
27 })
28 })