Aktueller Stand

This commit is contained in:
2026-01-22 19:05:45 +01:00
parent 85dee61a4d
commit e280e4eadb
1967 changed files with 397327 additions and 74093 deletions

View File

@@ -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`

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
})

View File

@@ -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)
}
})
}