基本schema测试

This commit is contained in:
2025-09-22 16:00:32 +08:00
commit b70b69c886
2754 changed files with 408678 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
'use strict'
const assert = require('node:assert/strict')
const { test } = require('node:test')
const { mergeSchemas } = require('../index')
const { defaultResolver } = require('./utils')
test('should return an empty schema if passing an empty array', () => {
const mergedSchema = mergeSchemas([], { defaultResolver })
assert.deepStrictEqual(mergedSchema, {})
})
test('should return true if passing all true values', () => {
const mergedSchema = mergeSchemas([true, true, true], { defaultResolver })
assert.deepStrictEqual(mergedSchema, true)
})
test('should return true if passing all false values', () => {
const mergedSchema = mergeSchemas([false, false, false], { defaultResolver })
assert.deepStrictEqual(mergedSchema, false)
})
test('should return true if passing at least one false schema', () => {
const schema1 = { type: 'string' }
const schema2 = { type: 'number' }
const mergedSchema = mergeSchemas([schema1, schema2, false], { defaultResolver })
assert.deepStrictEqual(mergedSchema, false)
})