1
0
Fork 0

test context merge, yaml parser

This commit is contained in:
Sean Sube 2019-07-01 22:32:21 -05:00
parent 661bb5a255
commit 18751f8ec7
2 changed files with 46 additions and 3 deletions

View File

@ -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);
});
});
});

View File

@ -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);
});
});