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
|
|
|
|
2019-09-11 01:08:57 +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({
|
2019-09-11 01:08:57 +00:00
|
|
|
innerOptions: {
|
|
|
|
coerce: false,
|
|
|
|
defaults: false,
|
|
|
|
mutate: false,
|
|
|
|
},
|
2019-07-02 03:32:21 +00:00
|
|
|
logger: new ConsoleLogger(),
|
|
|
|
});
|
|
|
|
|
|
|
|
const nextCtx = firstCtx.mergeResult({
|
2019-11-03 22:11:25 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
});
|