source: node_modules/json-stable-stringify/test/str.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 765 bytes
Line 
1'use strict';
2
3var test = require('tape');
4var stringify = require('../');
5
6test('simple object', function (t) {
7 t.plan(1);
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}');
10});
11
12test('object with undefined', function (t) {
13 t.plan(1);
14 var obj = { a: 3, z: undefined };
15 t.equal(stringify(obj), '{"a":3}');
16});
17
18test('array with undefined', function (t) {
19 t.plan(1);
20 var obj = [4, undefined, 6];
21 t.equal(stringify(obj), '[4,null,6]');
22});
23
24test('object with empty string', function (t) {
25 t.plan(1);
26 var obj = { a: 3, z: '' };
27 t.equal(stringify(obj), '{"a":3,"z":""}');
28});
29
30test('array with empty string', function (t) {
31 t.plan(1);
32 var obj = [4, '', 6];
33 t.equal(stringify(obj), '[4,"",6]');
34});
Note: See TracBrowser for help on using the repository browser.