We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 21e95e5 commit 0a50205Copy full SHA for 0a50205
test/space.js
@@ -70,3 +70,29 @@ test('space parameter (same as native)', function (t) {
70
JSON.stringify(obj, null, ' ')
71
);
72
});
73
+
74
+test('space parameter, on a cmp function', function (t) {
75
+ t.plan(3);
76
+ var obj = { one: 1, two: 2 };
77
+ var cmp = function (a, b) {
78
+ return a < b ? 1 : -1;
79
+ };
80
81
+ t.equal(
82
+ stringify(obj, { space: '\t' }),
83
+ '{\n\t"one": 1,\n\t"two": 2\n}',
84
+ 'no cmp option (control)'
85
+ );
86
87
+ stringify(obj, { cmp: cmp, space: '\t' }),
88
+ '{\n\t"two": 2,\n\t"one": 1\n}',
89
+ 'cmp option in the object'
90
91
92
+ cmp.space = '\t';
93
94
+ stringify(obj, cmp),
95
96
+ 'cmp passed directly, with space option on it'
97
98
+});
0 commit comments