]>
git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/pretty-json/node_modules/json-stable-stringify/test/to-json.js
1 var test
= require('tape');
2 var stringify
= require('../');
4 test('toJSON function', function (t
) {
6 var obj
= { one: 1, two: 2, toJSON: function() { return { one: 1 }; } };
7 t
.equal(stringify(obj
), '{"one":1}' );
10 test('toJSON returns string', function (t
) {
12 var obj
= { one: 1, two: 2, toJSON: function() { return 'one'; } };
13 t
.equal(stringify(obj
), '"one"');
16 test('toJSON returns array', function (t
) {
18 var obj
= { one: 1, two: 2, toJSON: function() { return ['one']; } };
19 t
.equal(stringify(obj
), '["one"]');