fix(tests): cover rule module error handling, exclude by level
This commit is contained in:
parent
c0eb3e0bfc
commit
b3fa9dd9be
|
@ -157,5 +157,20 @@ describeLeaks('load rule module helper', async () => {
|
|||
expect(rules.length).to.equal(1);
|
||||
});
|
||||
|
||||
itLeaks('should handle errors loading rule modules', async () => {
|
||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||
const requireStub = stub().throws(new Error('could not load this module')) as any;
|
||||
const ctx = new VisitorContext({
|
||||
logger: NullLogger.global,
|
||||
schemaOptions: {
|
||||
coerce: false,
|
||||
defaults: false,
|
||||
mutate: false,
|
||||
},
|
||||
});
|
||||
|
||||
return expect(loadRuleModules(['test'], ctx, requireStub)).to.eventually.deep.equal([]);
|
||||
});
|
||||
|
||||
itLeaks('should validate rule module exports');
|
||||
});
|
||||
|
|
|
@ -97,6 +97,18 @@ describeLeaks('rule resolver', async () => {
|
|||
expect(rules[0]).to.equal(TEST_RULES[0]);
|
||||
});
|
||||
});
|
||||
|
||||
describeLeaks('exclude by level', async () => {
|
||||
itLeaks('should exclude warn rules', async () => {
|
||||
const rules = await resolveRules(TEST_RULES, createRuleSelector({
|
||||
excludeLevel: [LogLevel.Warn],
|
||||
includeTag: ['all'],
|
||||
}));
|
||||
|
||||
expect(rules.length).to.equal(1);
|
||||
expect(rules[0]).to.equal(TEST_RULES[0]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('create rule sources helper', () => {
|
||||
|
|
Loading…
Reference in New Issue