Projektstart
This commit is contained in:
48
backend/node_modules/fast-json-stringify/test/requiresAjv.test.js
generated
vendored
Normal file
48
backend/node_modules/fast-json-stringify/test/requiresAjv.test.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict'
|
||||
|
||||
const t = require('tap')
|
||||
const build = require('..')
|
||||
|
||||
t.test('nested ref requires ajv', async t => {
|
||||
const schemaA = {
|
||||
$id: 'urn:schema:a',
|
||||
definitions: {
|
||||
foo: { anyOf: [{ type: 'string' }, { type: 'null' }] }
|
||||
}
|
||||
}
|
||||
|
||||
const schemaB = {
|
||||
$id: 'urn:schema:b',
|
||||
type: 'object',
|
||||
properties: {
|
||||
results: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
bar: {
|
||||
type: 'array',
|
||||
items: { $ref: 'urn:schema:a#/definitions/foo' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const stringify = build(schemaB, {
|
||||
schema: {
|
||||
[schemaA.$id]: schemaA
|
||||
}
|
||||
})
|
||||
const result = stringify({
|
||||
results: {
|
||||
items: {
|
||||
bar: ['baz']
|
||||
}
|
||||
}
|
||||
})
|
||||
t.same(result, '{"results":{"items":{"bar":["baz"]}}}')
|
||||
})
|
||||
Reference in New Issue
Block a user