|
| 1 | +import { test, describe } from 'node:test'; |
| 2 | +import assert from 'node:assert/strict'; |
| 3 | +import { createRequire } from 'node:module'; |
| 4 | + |
| 5 | +import { config } from '../dist/config.js'; |
| 6 | + |
| 7 | +const require = createRequire(import.meta.url); |
| 8 | + |
| 9 | +describe('excludedOptions', () => { |
| 10 | + test('default config excludes idRandomization, fontFamily, fontWeight, title', () => { |
| 11 | + assert.deepEqual(config.excludedOptions, [ |
| 12 | + 'idRandomization', |
| 13 | + 'fontFamily', |
| 14 | + 'fontWeight', |
| 15 | + 'title', |
| 16 | + ]); |
| 17 | + }); |
| 18 | + |
| 19 | + test('excluded options are removed from options schema', () => { |
| 20 | + // Load a fresh copy of the schema to compare |
| 21 | + const originalSchema = JSON.parse( |
| 22 | + JSON.stringify(require('@dicebear/schema/options.json')), |
| 23 | + ); |
| 24 | + |
| 25 | + for (const key of config.excludedOptions) { |
| 26 | + assert.ok( |
| 27 | + key in originalSchema.properties, |
| 28 | + `"${key}" should exist in the original schema`, |
| 29 | + ); |
| 30 | + } |
| 31 | + |
| 32 | + // Simulate the filtering logic from routes/style.ts |
| 33 | + for (const key of config.excludedOptions) { |
| 34 | + delete originalSchema.properties[key]; |
| 35 | + } |
| 36 | + |
| 37 | + for (const key of config.excludedOptions) { |
| 38 | + assert.ok( |
| 39 | + !(key in originalSchema.properties), |
| 40 | + `"${key}" should be removed after filtering`, |
| 41 | + ); |
| 42 | + } |
| 43 | + }); |
| 44 | +}); |
0 commit comments