Files
LWLT-AI/node_modules/fast-json-stringify/test/invalidSchema.test.js
2026-07-13 19:57:46 +08:00

39 lines
687 B
JavaScript

'use strict'
const { test } = require('node:test')
const build = require('..')
// Covers issue #139
test('Should throw on invalid schema', t => {
t.plan(1)
t.assert.throws(() => {
build({}, {
schema: {
invalid: {
type: 'Dinosaur'
}
}
})
}, { message: /^"invalid" schema is invalid:.*/ })
})
test('invalid not schema', (t) => {
t.plan(1)
const schema = {
type: 'object',
properties: {
prop: {
not: 'not object' // invalid, not must be object
}
}
}
try {
build(schema)
t.assert.fail('Should throw')
} catch (err) {
t.assert.ok(err.message.includes('schema is invalid'))
}
})