master-zapier-plan-draft/vendor/zapier-platform/packages/schema/test/utils.js
George Lambert b4150c8250 Milestone 0: import zappier billing, Verae middleware, and Zapier research
Compose-ready workspace: packages/zappier (rate card, portal, Stripe),
packages/verae-zapier-middleware (timestamp + NATS), packages/verae-zapier
(CLI app), vendor/zapier-platform, and research/zapier vendor corpus.

Gate 0 structure checks pass. Product code and research are not yet wired.
2026-09-09 02:37:36 -04:00

46 lines
1.1 KiB
JavaScript

'use strict';
require('should');
const { SKIP_KEY } = require('../lib/constants');
const testInlineSchemaExamples = (name) => {
const Schema = require('../lib/schemas/' + name);
const goods = Schema.schema.examples || [];
const bads = Schema.schema.antiExamples || [];
describe(name, () => {
it('valid example schemas should pass validation', function () {
if (!goods.length) {
this.skip();
} else {
goods
.filter((t) => !t[SKIP_KEY])
.forEach((good) => {
const { errors } = Schema.validate(good);
errors.should.have.length(0);
});
}
});
it('invalid example schemas should fail validation', function () {
if (!bads.length) {
this.skip();
} else {
bads
.filter((t) => !t[SKIP_KEY])
.map((t) => t.example)
.forEach((bad) => {
const { errors } = Schema.validate(bad);
if (errors.length === 0) {
console.log(bad);
}
errors.should.not.have.length(0);
});
}
});
});
};
module.exports = {
testInlineSchemaExamples,
};