]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/pretty-json/node_modules/json-stable-stringify/test/to-json.js
Merge master
[rbdr/dotfiles] / atom / packages / pretty-json / node_modules / json-stable-stringify / test / to-json.js
1 var test = require('tape');
2 var stringify = require('../');
3
4 test('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
10 test('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
16 test('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 });