25 lines
608 B
TypeScript
25 lines
608 B
TypeScript
import { expect } from 'chai';
|
|
import { ConsoleLogger } from 'noicejs';
|
|
|
|
import { VisitorContext } from '../../src/visitor/context';
|
|
|
|
describe('visitor context', () => {
|
|
it('should merge results', () => {
|
|
const firstCtx = new VisitorContext({
|
|
coerce: false,
|
|
defaults: false,
|
|
logger: new ConsoleLogger(),
|
|
mutate: false,
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|