diff --git a/test/parser/TestYamlParser.ts b/test/parser/TestYamlParser.ts new file mode 100644 index 0000000..062dd28 --- /dev/null +++ b/test/parser/TestYamlParser.ts @@ -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); + }); + }); +}); diff --git a/test/visitor/TestContext.ts b/test/visitor/TestContext.ts index 066800d..22d0a4b 100644 --- a/test/visitor/TestContext.ts +++ b/test/visitor/TestContext.ts @@ -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); }); });