test context merge, yaml parser
This commit is contained in:
parent
661bb5a255
commit
18751f8ec7
|
@ -0,0 +1,28 @@
|
|||
import { expect } from 'chai';
|
||||
import { mock } from 'sinon';
|
||||
import { YamlParser } from 'src/parser/YamlParser';
|
||||
|
||||
describe('yaml parser', () => {
|
||||
describe('dump documents', () => {
|
||||
it('should dump multiple documents', () => {
|
||||
const parser = new YamlParser();
|
||||
const data = parser.dump({}, {});
|
||||
|
||||
expect(data).to.contain('---');
|
||||
});
|
||||
});
|
||||
|
||||
describe('parse documents', () => {
|
||||
it('should parse multiple documents', () => {
|
||||
const parser = new YamlParser();
|
||||
const data = parser.parse(`
|
||||
foo: {}
|
||||
---
|
||||
bar: {}
|
||||
`);
|
||||
|
||||
expect(Array.isArray(data)).to.equal(true);
|
||||
expect(data.length).to.equal(2);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,7 +1,22 @@
|
|||
import { expect } from 'chai';
|
||||
import { VisitorContext } from 'src/visitor/context';
|
||||
import { ConsoleLogger } from 'noicejs';
|
||||
|
||||
describe('context', () => {
|
||||
it('tests things', () => {
|
||||
expect(true).to.equal(true);
|
||||
describe('visitor context', () => {
|
||||
it('should merge results', () => {
|
||||
const firstCtx = new VisitorContext({
|
||||
coerce: false,
|
||||
defaults: false,
|
||||
logger: new ConsoleLogger(),
|
||||
});
|
||||
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue