3 var test = require('tape');
4 var stringify = require('../');
6 test('simple object', function (t) {
8 var obj = { c: 6, b: [4,5], a: 3, z: null };
9 t.equal(stringify(obj), '{"a":3,"b":[4,5],"c":6,"z":null}');
12 test('object with undefined', function (t) {
14 var obj = { a: 3, z: undefined };
15 t.equal(stringify(obj), '{"a":3}');
18 test('object with null', function (t) {
20 var obj = { a: 3, z: null };
21 t.equal(stringify(obj), '{"a":3,"z":null}');
24 test('object with NaN and Infinity', function (t) {
26 var obj = { a: 3, b: NaN, c: Infinity };
27 t.equal(stringify(obj), '{"a":3,"b":null,"c":null}');
30 test('array with undefined', function (t) {
32 var obj = [4, undefined, 6];
33 t.equal(stringify(obj), '[4,null,6]');
36 test('object with empty string', function (t) {
38 var obj = { a: 3, z: '' };
39 t.equal(stringify(obj), '{"a":3,"z":""}');
42 test('array with empty string', function (t) {
45 t.equal(stringify(obj), '[4,"",6]');