diff --git a/.travis.yml b/.travis.yml index 6758eeb..3d6153d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: node_js sudo: false node_js: +- '6' - '4' -- '3' -- '2' -- '1' - '0.12' - '0.10' script: diff --git a/Changelog.md b/Changelog.md index 9e31366..f072ee5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +# 0.2.2 - 2016-04-28 + +- Upgrade minim peerDependency to 0.14.0 +- Upgrade minim-api-description dependency to 0.1.4 + # 0.2.1 - 2015-11-24 - Fix a bug that was caused by overwriting the base element. This is now accomplished in another way. diff --git a/README.md b/README.md index 2b253f2..9022585 100644 --- a/README.md +++ b/README.md @@ -81,10 +81,6 @@ import parseResult from 'minim-parse-result'; const namespace = minim.namespace() .use(parseResult); -// Convert from Compact Refract -let compactRefract = ['parseResult', {}, {}, []]; -let api = namespace.fromCompactRefract(compactRefract); - // Initialize elements directly const ParseResult = namespace.getElementClass('parseResult'); let category = new ParseResult(); diff --git a/package.json b/package.json index 190d268..14df0eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minim-parse-result", - "version": "0.2.1", + "version": "0.2.2", "description": "Minim Parse Result Namespace", "main": "./lib/parse-result.js", "repository": { @@ -18,12 +18,12 @@ }, "dependencies": { "babel-runtime": "^5.8.20", - "minim-api-description": "^0.1.0" + "minim-api-description": "^0.1.4" }, "devDependencies": { "chai": "^3.2.0", "coveralls": "^2.11.2", - "minim": "^0.13.0", + "minim": "^0.14.0", "peasant": "^0.5.2" }, "author": "Apiary.io ", diff --git a/src/parse-result.js b/src/parse-result.js index 7404c4b..9a25ef7 100644 --- a/src/parse-result.js +++ b/src/parse-result.js @@ -14,11 +14,6 @@ export function namespace(options) { const ArrayElement = minim.getElementClass('array'); const StringElement = minim.getElementClass('string'); - // First, modify the default list of special attributes to include - // the new `sourceMap` attribute, which is an unrefracted array of - // refracted source map elements. - minim._attributeElementArrayKeys.push('sourceMap'); - class ParseResult extends ArrayElement { constructor() { super(...arguments); diff --git a/test/parse-result.js b/test/parse-result.js index 72f400a..8f16048 100644 --- a/test/parse-result.js +++ b/test/parse-result.js @@ -43,15 +43,46 @@ function attrValue(element, name) { describe('Parse result namespace', () => { context('parse result element', () => { let parseResult; + let refracted; beforeEach(() => { - parseResult = (new ParseResult()).fromCompactRefract([ - 'parseResult', {}, {}, [ - ['annotation', {classes: ['warning']}, {}, []], - ['annotation', {classes: ['error']}, {}, []], - ['category', {classes: ['api']}, {}, []], + refracted = { + element: 'parseResult', + meta: {}, + attributes: {}, + content: [ + { + element: 'annotation', + meta: { + classes: ['warning'], + }, + attributes: {}, + content: [], + }, + { + element: 'annotation', + meta: { + classes: ['error'], + }, + attributes: {}, + content: [], + }, + { + element: 'category', + meta: { + classes: ['api'], + }, + attributes: {}, + content: [], + }, ], - ]); + }; + + parseResult = (new ParseResult()).fromRefract(refracted); + }); + + it('should round-trip correctly', () => { + expect(parseResult.toRefract()).to.deep.equal(refracted); }); it('should have element name parseResult', () => { @@ -93,11 +124,23 @@ describe('Parse result namespace', () => { context('annotation element', () => { let annotation; + let refracted; beforeEach(() => { - annotation = (new Annotation()).fromCompactRefract([ - 'annotation', {}, {code: 123}, 'Missing argument description', - ]); + refracted = { + element: 'annotation', + meta: {}, + attributes: { + code: 123, + }, + content: 'Missing argument description', + }; + + annotation = (new Annotation()).fromRefract(refracted); + }); + + it('should round-trip correctly', () => { + expect(annotation.toRefract()).to.deep.equal(refracted); }); it('should have element name annotation', () => { @@ -122,9 +165,12 @@ describe('Parse result namespace', () => { let sourceMap; beforeEach(() => { - sourceMap = (new SourceMap()).fromCompactRefract([ - 'sourceMap', {}, {}, [], - ]); + sourceMap = (new SourceMap()).fromRefract({ + element: 'sourceMap', + meta: {}, + attributes: {}, + content: [], + }); }); it('should have element name sourceMap', () => { @@ -135,18 +181,33 @@ describe('Parse result namespace', () => { context('source maps', () => { let element; let sourceMaps; + let refracted; beforeEach(() => { - element = (new StringElement()).fromCompactRefract([ - 'string', {}, { + refracted = { + element: 'string', + meta: {}, + attributes: { sourceMap: [ - ['sourceMap', {}, {}, [[1, 2]]], + { + element: 'sourceMap', + meta: {}, + attributes: {}, + content: [[1, 2]], + }, ], - }, [], - ]); + }, + content: [], + }; + + element = (new StringElement()).fromRefract(refracted); sourceMaps = element.attributes.get('sourceMap'); }); + it('should round-trip correctly', () => { + expect(element.toRefract()).to.deep.equal(refracted); + }); + it('should contain a sourceMap attribute with one item', () => { expect(sourceMaps).to.exist; expect(sourceMaps).to.have.length(1); @@ -166,9 +227,7 @@ describe('Parse result namespace', () => { element: 'sourceMap', meta: {}, attributes: {}, - content: [ - [1, 2], - ], + content: [[1, 2]], }, ], },