blob: 67426b99e30b2265e66302ea04ab1cc1a010f477 [file] [log] [blame]
Yang Guo4fd355c2019-09-19 10:59:03 +02001var test = require('tape');
2var stringify = require('../');
3
4test('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
10test('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
16test('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
22test('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
28test('array with empty string', function (t) {
29 t.plan(1);
30 var obj = [4, '', 6];
31 t.equal(stringify(obj), '[4,"",6]');
32});