1
0
Fork 0

cover rule module defs directly

This commit is contained in:
ssube 2019-11-17 17:45:12 -06:00 committed by Sean Sube
parent 089725ef60
commit 61498e7fab
1 changed files with 29 additions and 5 deletions

View File

@ -167,11 +167,6 @@ describeLeaks('load rule module helper', async () => {
}, },
}); });
const requireStub = stub().withArgs('test').returns({ const requireStub = stub().withArgs('test').returns({
definitions: {
foo: {
type: 'string',
},
},
name: 'test', name: 'test',
rules: [{ rules: [{
check: {}, check: {},
@ -218,4 +213,33 @@ describeLeaks('load rule module helper', async () => {
return expect(loadRuleModules(['test'], ctx, requireStub)).to.eventually.deep.equal([]); return expect(loadRuleModules(['test'], ctx, requireStub)).to.eventually.deep.equal([]);
}); });
itLeaks('should load module definitions', async () => {
const requireStub = stub().returns({
definitions: {
foo: {
type: 'string',
},
},
name: 'test-rules',
rules: [],
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
}) as any;
const ctx = new VisitorContext({
logger: NullLogger.global,
schemaOptions: {
coerce: false,
defaults: false,
mutate: false,
},
});
await loadRuleModules(['test'], ctx, requireStub);
const schema = ctx.compile({
$ref: 'test-rules#/definitions/foo',
});
expect(schema(2)).to.equal(false);
expect(schema('foo')).to.equal(true);
});
}); });