tachybase_todo/packages/father-build/src/schema.test.ts
2021-05-23 08:38:08 +08:00

39 lines
1.0 KiB
TypeScript
Executable File

import AJV from 'ajv';
import schema from './schema';
const ajv = new AJV();
const successValidates = {
entry: ['a', ['a']],
file: ['a'],
esm: [false, true, { type: 'rollup' }, { type: 'babel' }, { file: 'a' }, { mjs: true }],
cjs: [false, true, { type: 'rollup' }, { type: 'babel' }, { file: 'a' }],
umd: [{ globals: {} }, { file: 'a' }, { name: 'a' }, { minFile: false }, { minFile: true }, { sourcemap: true }],
extraBabelPlugins: [[]],
extraBabelPresets: [[]],
extraPostCSSPlugins: [[]],
lessInRollupMode: [{}],
cssModules: [true, false, {}],
autoprefixer: [{}],
include: ['node_modules', /node_modules/],
nodeResolveOpts: [{}],
runtimeHelpers: [true, false],
target: ['node', 'browser'],
overridesByEntry: [{}],
doc: [{}],
typescriptOpts: [{}],
pkgs: [[]],
};
Object.keys(successValidates).forEach(key => {
test(key, () => {
successValidates[key].forEach(item => {
expect(
ajv.validate(schema, {
[key]: item,
}),
).toEqual(true);
});
});
});