Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialise parseResult and link empty array content #202

Merged
merged 2 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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