source: trip-planner-front/node_modules/fast-json-stable-stringify/test/to-json.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

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