Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('should support rule overriding severity', () => {
spectral.addFunctions({
func1: () => {
return [
{
message: 'foo',
},
];
},
});
spectral.addRules({
rule1: {
given: '$.x',
severity: ValidationSeverity.Info,
severityLabel: ValidationSeverityLabel.Info,
then: {
function: 'func1',
},
},
});
const result = spectral.run({
x: true,
});
expect(result.results[0].severity).toEqual(ValidationSeverity.Info);
expect(result.results[0].severityLabel).toEqual(ValidationSeverityLabel.Info);
});
rule1: {
given: '$.x',
severity: ValidationSeverity.Info,
severityLabel: ValidationSeverityLabel.Info,
then: {
function: 'func1',
},
},
});
const result = spectral.run({
x: true,
});
expect(result.results[0].severity).toEqual(ValidationSeverity.Info);
expect(result.results[0].severityLabel).toEqual(ValidationSeverityLabel.Info);
});