source: imaps-frontend/node_modules/fast-json-stable-stringify/test/str.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[d565449]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('object with null', function (t) {
19 t.plan(1);
20 var obj = { a: 3, z: null };
21 t.equal(stringify(obj), '{"a":3,"z":null}');
22});
23
24test('object with NaN and Infinity', function (t) {
25 t.plan(1);
26 var obj = { a: 3, b: NaN, c: Infinity };
27 t.equal(stringify(obj), '{"a":3,"b":null,"c":null}');
28});
29
30test('array with undefined', function (t) {
31 t.plan(1);
32 var obj = [4, undefined, 6];
33 t.equal(stringify(obj), '[4,null,6]');
34});
35
36test('object with empty string', function (t) {
37 t.plan(1);
38 var obj = { a: 3, z: '' };
39 t.equal(stringify(obj), '{"a":3,"z":""}');
40});
41
42test('array with empty string', function (t) {
43 t.plan(1);
44 var obj = [4, '', 6];
45 t.equal(stringify(obj), '[4,"",6]');
46});
Note: See TracBrowser for help on using the repository browser.