Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

Commit

Permalink
Merge pull request #7 from refractproject/pksunkara/minim-14
Browse files Browse the repository at this point in the history
Upgrade to minim 0.14.0 and Release 0.2.2
  • Loading branch information
smizell committed Apr 28, 2016
2 parents b0a5d76 + b0529a3 commit 9d7a75f
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 35 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: node_js
sudo: false
node_js:
- '6'
- '4'
- '3'
- '2'
- '1'
- '0.12'
- '0.10'
script:
Expand Down
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -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 <support@apiary.io>",
Expand Down
5 changes: 0 additions & 5 deletions src/parse-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
99 changes: 79 additions & 20 deletions test/parse-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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);
Expand All @@ -166,9 +227,7 @@ describe('Parse result namespace', () => {
element: 'sourceMap',
meta: {},
attributes: {},
content: [
[1, 2],
],
content: [[1, 2]],
},
],
},
Expand Down

0 comments on commit 9d7a75f

Please sign in to comment.