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-08-30 05:24:12 +00:00
|
|
|
import { VisitorContext } from '../../src/visitor/context';
|
|
|
|
|
2019-07-02 03:32:21 +00:00
|
|
|
describe('visitor context', () => {
|
|
|
|
it('should merge results', () => {
|
|
|
|
const firstCtx = new VisitorContext({
|
|
|
|
coerce: false,
|
|
|
|
defaults: false,
|
|
|
|
logger: new ConsoleLogger(),
|
2019-07-11 05:16:00 +00:00
|
|
|
mutate: false,
|
2019-07-02 03:32:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
const nextCtx = firstCtx.mergeResult({
|
|
|
|
changes: [{bar: 3}],
|
|
|
|
errors: [{foo: 2}],
|
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|