Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
Updates coercion fixtures to fix broken tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
c4milo committed Jun 23, 2015
1 parent 22fee58 commit 52e5df3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/fixtures/coerce.json
@@ -1 +1 @@
{"itemRecord":{"value":[{"longValue":"12345"},{"stringValue":{"number":"false","$t":"this is a string value"}},{"moneyValue":{"number":"true","currencyId":"USD","$t":"104.95"}},{"moneyValue":{"currencyId":"USD","$t":"104.95"}},{"longValue":"0","bool":{"id":"0","$t":"true"}},{"longValue":"0"},{"dateValue":"2012-02-16T17:03:33.000-07:00"},{"stringValue":"SmDZ8RlMIjDvlEW3KUibzj2Q"}]}}
{"itemRecord":{"value":[{"longValue":"12345"},{"stringValue":{"number":"false","$t":"this is a string value"}},{"moneyValue":{"number":"true","currencyId":"USD","text":"123.45","$t":"104.95"}},{"moneyValue":{"currencyId":"USD","$t":"104.95"}},{"longValue":"0","bool":{"id":"0","$t":"true"}},{"longValue":"0"},{"dateValue":"2012-02-16T17:03:33.000-07:00"},{"stringValue":"SmDZ8RlMIjDvlEW3KUibzj2Q"},{"text":"42.42"}]}}
2 changes: 1 addition & 1 deletion test/test-coerce.js
Expand Up @@ -26,7 +26,7 @@ assert.strictEqual(result.itemRecord.value[2].moneyValue['$t'], '104.95');
assert.strictEqual(result.itemRecord.value[2].moneyValue.text, '123.45');
assert.strictEqual(result.itemRecord.value[8].text['$t'], '42.42');

// With coercien as an optional object
// With coercion as an optional object
var result = parser.toJson(data, {reversible: true, coerce: {text:String}, object: true});
assert.strictEqual(result.itemRecord.value[0].longValue['$t'], 12345);
assert.strictEqual(result.itemRecord.value[1].stringValue.number, false);
Expand Down
2 changes: 2 additions & 0 deletions test/test.js
Expand Up @@ -37,9 +37,11 @@ fs.readdir(fixturesPath, function(err, files) {
if (expected) {
expected = expected.trim();
}
// console.log('============ Got ===============');
// console.log(result);
// console.log('============ Expected ===============');
// console.log(expected)
// console.log('=====================================');
assert.deepEqual(result, expected, jsonFile + ' and ' + file + ' are different');
console.log('[xml2json: ' + file + '->' + jsonFile + '] passed!');
} else if( ext == '.json') {
Expand Down

0 comments on commit 52e5df3

Please sign in to comment.