source: imaps-frontend/node_modules/json-stable-stringify-without-jsonify/test/to-json.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 574 bytes
Line 
1var test = require('tape');
2var stringify = require('../');
3
4test('toJSON function', function (t) {
5 t.plan(1);
6 var obj = { one: 1, two: 2, toJSON: function() { return { one: 1 }; } };
7 t.equal(stringify(obj), '{"one":1}' );
8});
9
10test('toJSON returns string', function (t) {
11 t.plan(1);
12 var obj = { one: 1, two: 2, toJSON: function() { return 'one'; } };
13 t.equal(stringify(obj), '"one"');
14});
15
16test('toJSON returns array', function (t) {
17 t.plan(1);
18 var obj = { one: 1, two: 2, toJSON: function() { return ['one']; } };
19 t.equal(stringify(obj), '["one"]');
20});
Note: See TracBrowser for help on using the repository browser.