Skip to content

Commit

Permalink
Merge pull request #202 from refractproject/kylef/serialise-array
Browse files Browse the repository at this point in the history
Serialise parseResult and link empty array content
  • Loading branch information
kylef committed Nov 28, 2018
2 parents 73170ca + 933e53d commit beeddee
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Minim Changelog

## 0.21.1

### Bug Fixes

- Empty parseResult and link arrays are serialised in JSON 06 Serialiser, a
regression of 0.21.0 caused these to not be serialised.

## 0.21.0

### Breaking
Expand Down
5 changes: 4 additions & 1 deletion lib/serialisers/json-0.6.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ module.exports = JSONSerialiser.extend({
return false;
}

if (element.element === 'httpRequest' || element.element === 'httpResponse' || element.element === 'category') {
if (element.element === 'parseResult' || element.element === 'httpRequest' ||
element.element === 'httpResponse' || element.element === 'category' ||
element.element === 'link')
{
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minim",
"version": "0.21.0",
"version": "0.21.1",
"description": "A library for interacting with JSON through Refract elements",
"main": "lib/minim.js",
"scripts": {
Expand Down
22 changes: 22 additions & 0 deletions test/serialisers/json-0.6.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,17 @@ describe('JSON 0.6 Serialiser', function() {
});
});

it('serialises empty parseResult content', function() {
var element = new minim.elements.Element([]);
element.element = 'parseResult';
var serialised = serialiser.serialise(element);

expect(serialised).to.deep.equal({
element: 'parseResult',
content: []
});
});

it('serialises empty httpRequest content', function() {
var element = new minim.elements.Element([]);
element.element = 'httpRequest';
Expand All @@ -842,6 +853,17 @@ describe('JSON 0.6 Serialiser', function() {
});
});

it('serialises empty link content', function() {
var element = new minim.elements.Element([]);
element.element = 'link';
var serialised = serialiser.serialise(element);

expect(serialised).to.deep.equal({
element: 'link',
content: [],
});
});

it('serialises empty category content', function() {
var element = new minim.elements.Element([]);
element.element = 'category';
Expand Down

0 comments on commit beeddee

Please sign in to comment.