1
0
Fork 0
salty-dog/test/utils/ajv/TestFriendlyErrors.ts

35 lines
874 B
TypeScript

import { expect } from 'chai';
import { NullLogger } from 'noicejs';
import { SchemaRule } from '../../../src/rule/SchemaRule';
import { friendlyError } from '../../../src/utils/ajv';
import { VisitorContext } from '../../../src/visitor/VisitorContext';
const TEST_NAME = 'test';
describe('friendly errors', () => {
it('should have a message', () => {
const err = friendlyError(new VisitorContext({
innerOptions: {
coerce: false,
defaults: false,
mutate: false,
},
logger: NullLogger.global,
}), {
dataPath: 'test-path',
keyword: TEST_NAME,
params: { /* ? */ },
schemaPath: 'test-path',
}, new SchemaRule({
check: {},
desc: TEST_NAME,
level: 'info',
name: TEST_NAME,
select: '',
tags: [TEST_NAME],
}));
expect(err.msg).to.not.equal('');
});
});