1
0
Fork 0
salty-dog/test/visitor/TestContext.ts

36 lines
780 B
TypeScript
Raw Normal View History

2019-06-29 01:24:17 +00:00
import { expect } from 'chai';
2019-07-02 03:32:21 +00:00
import { ConsoleLogger } from 'noicejs';
2019-06-29 01:24:17 +00:00
import { VisitorContext } from '../../src/visitor/VisitorContext';
2019-08-30 05:24:12 +00:00
2019-07-02 03:32:21 +00:00
describe('visitor context', () => {
it('should merge results', () => {
const firstCtx = new VisitorContext({
innerOptions: {
coerce: false,
defaults: false,
mutate: false,
},
2019-07-02 03:32:21 +00:00
logger: new ConsoleLogger(),
});
const nextCtx = firstCtx.mergeResult({
changes: [{
kind: 'N',
rhs: {},
}],
errors: [{
data: {
foo: 2,
},
level: 'info',
msg: 'uh oh',
}],
2019-07-02 03:32:21 +00:00
});
expect(nextCtx).to.equal(firstCtx);
expect(nextCtx.errors.length).to.equal(1);
expect(nextCtx.changes.length).to.equal(1);
2019-06-29 01:24:17 +00:00
});
});