Skip to content

Commit

Permalink
Emit empty string for nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
pcantrell authored and luissilvaos committed Jan 12, 2017
1 parent 290cb60 commit 3faaedf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,8 @@ function walk_obj(next, next_child) {
// a typed array
next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));

} else if (next === null) {
next_child.ele('string');

}
}
14 changes: 14 additions & 0 deletions test/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ describe('plist', function () {
*/}));
});

it('should emit an empty string for nulls', function () {
var xml = build({ a: null });
assert.strictEqual(xml, multiline(function () {/*
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>a</key>
<string/>
</dict>
</plist>
*/}));
});

it('should omit undefined values', function () {
var xml = build({ a: undefined });
assert.strictEqual(xml, multiline(function () {/*
Expand Down

0 comments on commit 3faaedf

Please sign in to comment.