Aktueller Stand
This commit is contained in:
54
backend/node_modules/fast-json-stringify/test/debug-mode.test.js
generated
vendored
54
backend/node_modules/fast-json-stringify/test/debug-mode.test.js
generated
vendored
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const { test } = require('node:test')
|
||||
const fjs = require('..')
|
||||
|
||||
const Ajv = require('ajv').default
|
||||
@@ -24,11 +24,11 @@ test('activate debug mode', t => {
|
||||
t.plan(5)
|
||||
const debugMode = build({ debugMode: true })
|
||||
|
||||
t.type(debugMode, 'object')
|
||||
t.ok(debugMode.ajv instanceof Ajv)
|
||||
t.ok(debugMode.validator instanceof Validator)
|
||||
t.ok(debugMode.serializer instanceof Serializer)
|
||||
t.type(debugMode.code, 'string')
|
||||
t.assert.ok(typeof debugMode === 'object')
|
||||
t.assert.ok(debugMode.ajv instanceof Ajv)
|
||||
t.assert.ok(debugMode.validator instanceof Validator)
|
||||
t.assert.ok(debugMode.serializer instanceof Serializer)
|
||||
t.assert.ok(typeof debugMode.code === 'string')
|
||||
})
|
||||
|
||||
test('activate debug mode truthy', t => {
|
||||
@@ -36,26 +36,26 @@ test('activate debug mode truthy', t => {
|
||||
|
||||
const debugMode = build({ debugMode: 'yes' })
|
||||
|
||||
t.type(debugMode, 'object')
|
||||
t.type(debugMode.code, 'string')
|
||||
t.ok(debugMode.ajv instanceof Ajv)
|
||||
t.ok(debugMode.validator instanceof Validator)
|
||||
t.ok(debugMode.serializer instanceof Serializer)
|
||||
t.assert.ok(typeof debugMode === 'object')
|
||||
t.assert.ok(typeof debugMode.code === 'string')
|
||||
t.assert.ok(debugMode.ajv instanceof Ajv)
|
||||
t.assert.ok(debugMode.validator instanceof Validator)
|
||||
t.assert.ok(debugMode.serializer instanceof Serializer)
|
||||
})
|
||||
|
||||
test('to string auto-consistent', t => {
|
||||
t.plan(6)
|
||||
const debugMode = build({ debugMode: 1 })
|
||||
|
||||
t.type(debugMode, 'object')
|
||||
t.type(debugMode.code, 'string')
|
||||
t.ok(debugMode.ajv instanceof Ajv)
|
||||
t.ok(debugMode.serializer instanceof Serializer)
|
||||
t.ok(debugMode.validator instanceof Validator)
|
||||
t.assert.ok(typeof debugMode === 'object')
|
||||
t.assert.ok(typeof debugMode.code === 'string')
|
||||
t.assert.ok(debugMode.ajv instanceof Ajv)
|
||||
t.assert.ok(debugMode.serializer instanceof Serializer)
|
||||
t.assert.ok(debugMode.validator instanceof Validator)
|
||||
|
||||
const compiled = fjs.restore(debugMode)
|
||||
const tobe = JSON.stringify({ firstName: 'Foo' })
|
||||
t.same(compiled({ firstName: 'Foo', surname: 'bar' }), tobe, 'surname evicted')
|
||||
t.assert.equal(compiled({ firstName: 'Foo', surname: 'bar' }), tobe, 'surname evicted')
|
||||
})
|
||||
|
||||
test('to string auto-consistent with ajv', t => {
|
||||
@@ -75,15 +75,15 @@ test('to string auto-consistent with ajv', t => {
|
||||
}
|
||||
}, { debugMode: 1 })
|
||||
|
||||
t.type(debugMode, 'object')
|
||||
t.type(debugMode.code, 'string')
|
||||
t.ok(debugMode.ajv instanceof Ajv)
|
||||
t.ok(debugMode.validator instanceof Validator)
|
||||
t.ok(debugMode.serializer instanceof Serializer)
|
||||
t.assert.ok(typeof debugMode === 'object')
|
||||
t.assert.ok(typeof debugMode.code === 'string')
|
||||
t.assert.ok(debugMode.ajv instanceof Ajv)
|
||||
t.assert.ok(debugMode.validator instanceof Validator)
|
||||
t.assert.ok(debugMode.serializer instanceof Serializer)
|
||||
|
||||
const compiled = fjs.restore(debugMode)
|
||||
const tobe = JSON.stringify({ str: 'Foo' })
|
||||
t.same(compiled({ str: 'Foo', void: 'me' }), tobe)
|
||||
t.assert.equal(compiled({ str: 'Foo', void: 'me' }), tobe)
|
||||
})
|
||||
|
||||
test('to string auto-consistent with ajv-formats', t => {
|
||||
@@ -104,12 +104,12 @@ test('to string auto-consistent with ajv-formats', t => {
|
||||
}
|
||||
}, { debugMode: 1 })
|
||||
|
||||
t.type(debugMode, 'object')
|
||||
t.assert.ok(typeof debugMode === 'object')
|
||||
|
||||
const compiled = fjs.restore(debugMode)
|
||||
const tobe = JSON.stringify({ str: 'foo@bar.com' })
|
||||
t.same(compiled({ str: 'foo@bar.com' }), tobe)
|
||||
t.throws(() => compiled({ str: 'foo' }))
|
||||
t.assert.equal(compiled({ str: 'foo@bar.com' }), tobe)
|
||||
t.assert.throws(() => compiled({ str: 'foo' }))
|
||||
})
|
||||
|
||||
test('debug should restore the same serializer instance', t => {
|
||||
@@ -117,5 +117,5 @@ test('debug should restore the same serializer instance', t => {
|
||||
|
||||
const debugMode = fjs({ type: 'integer' }, { debugMode: 1, rounding: 'ceil' })
|
||||
const compiled = fjs.restore(debugMode)
|
||||
t.same(compiled(3.95), 4)
|
||||
t.assert.equal(compiled(3.95), 4)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user