Aktueller Stand
This commit is contained in:
2
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md
generated
vendored
2
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md
generated
vendored
@@ -5,6 +5,6 @@ It contains a set of JSON objects that implementors of JSON Schema validation li
|
||||
|
||||
# How to add another test case?
|
||||
|
||||
1. Navigate to [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/master/tests)
|
||||
1. Navigate to [JSON-Schema-Test-Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite/tree/main/tests)
|
||||
2. Choose a draft `draft4`, `draft6` or `draft7`
|
||||
3. Copy & paste the `test-case.json` to the project and add a test like in the `draft4.test.js`
|
||||
6
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js
generated
vendored
6
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js
generated
vendored
@@ -1,12 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const { test } = require('node:test')
|
||||
const { counTests, runTests } = require('./util')
|
||||
|
||||
const requiredTestSuite = require('./draft4/required.json')
|
||||
|
||||
test('required', (t) => {
|
||||
test('required', async (t) => {
|
||||
const skippedTests = ['ignores arrays', 'ignores strings', 'ignores other non-objects']
|
||||
t.plan(counTests(requiredTestSuite, skippedTests))
|
||||
runTests(t, requiredTestSuite, skippedTests)
|
||||
await runTests(t, requiredTestSuite, skippedTests)
|
||||
})
|
||||
|
||||
6
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js
generated
vendored
6
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js
generated
vendored
@@ -1,12 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const { test } = require('node:test')
|
||||
const { counTests, runTests } = require('./util')
|
||||
|
||||
const requiredTestSuite = require('./draft6/required.json')
|
||||
|
||||
test('required', (t) => {
|
||||
test('required', async (t) => {
|
||||
const skippedTests = ['ignores arrays', 'ignores strings', 'ignores other non-objects']
|
||||
t.plan(counTests(requiredTestSuite, skippedTests))
|
||||
runTests(t, requiredTestSuite, skippedTests)
|
||||
await runTests(t, requiredTestSuite, skippedTests)
|
||||
})
|
||||
|
||||
6
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js
generated
vendored
6
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js
generated
vendored
@@ -1,12 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
const test = require('tap').test
|
||||
const { test } = require('node:test')
|
||||
const { counTests, runTests } = require('./util')
|
||||
|
||||
const requiredTestSuite = require('./draft7/required.json')
|
||||
|
||||
test('required', (t) => {
|
||||
test('required', async (t) => {
|
||||
const skippedTests = ['ignores arrays', 'ignores strings', 'ignores other non-objects']
|
||||
t.plan(counTests(requiredTestSuite, skippedTests))
|
||||
runTests(t, requiredTestSuite, skippedTests)
|
||||
await runTests(t, requiredTestSuite, skippedTests)
|
||||
})
|
||||
|
||||
15
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js
generated
vendored
15
backend/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js
generated
vendored
@@ -2,25 +2,22 @@
|
||||
|
||||
const build = require('../..')
|
||||
|
||||
function runTests (t, testsuite, skippedTests) {
|
||||
async function runTests (t, testsuite, skippedTests) {
|
||||
for (const scenario of testsuite) {
|
||||
const stringify = build(scenario.schema)
|
||||
for (const test of scenario.tests) {
|
||||
if (skippedTests.indexOf(test.description) !== -1) {
|
||||
t.comment('skip %s', test.description)
|
||||
console.log(`skip ${test.description}`)
|
||||
continue
|
||||
}
|
||||
t.test(test.description, (t) => {
|
||||
|
||||
await t.test(test.description, (t) => {
|
||||
t.plan(1)
|
||||
try {
|
||||
const output = stringify(test.data)
|
||||
t.equal(output, JSON.stringify(test.data), 'compare payloads')
|
||||
t.assert.equal(output, JSON.stringify(test.data), 'compare payloads')
|
||||
} catch (err) {
|
||||
if (test.valid === false) {
|
||||
t.pass('payload is invalid')
|
||||
} else {
|
||||
t.fail('payload should be valid: ' + err.message)
|
||||
}
|
||||
t.assert.ok(test.valid === false, 'payload should be valid: ' + err.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user