Debian Codegraph @

node/json-stable-stringify-without-jsonify/test/str.js

raw
1 var test = require('tape');
2 var stringify = require('../');
3
4 test('simple object', function (t) {
5 t.plan(1);
6 var obj = { c: 6, b: [4,5], a: 3, z: null };
7 t.equal(stringify(obj), '{"a":3,"b":[4,5],"c":6,"z":null}');
8 });
9
10 test('object with undefined', function (t) {
11 t.plan(1);
12 var obj = { a: 3, z: undefined };
13 t.equal(stringify(obj), '{"a":3}');
14 });
15
16 test('array with undefined', function (t) {
17 t.plan(1);
18 var obj = [4, undefined, 6];
19 t.equal(stringify(obj), '[4,null,6]');
20 });
21
22 test('object with empty string', function (t) {
23 t.plan(1);
24 var obj = { a: 3, z: '' };
25 t.equal(stringify(obj), '{"a":3,"z":""}');
26 });
27
28 test('array with empty string', function (t) {
29 t.plan(1);
30 var obj = [4, '', 6];
31 t.equal(stringify(obj), '[4,"",6]');
32 });