Urara-Blog/node_modules/.pnpm-store/v3/files/f4/7c85f1571773f8f03accbff18d11b329450057f390cbcb81be6457c88302e06b587a936210783e71e6cdfa45cf7d347bd9d167e04a91252457524d273ce1c8
2022-08-14 01:14:53 +08:00

22 lines
607 B
Text

'use strict';
var test = require('tape');
var stringify = require('../');
test('toJSON function', function (t) {
t.plan(1);
var obj = { one: 1, two: 2, toJSON: function() { return { one: 1 }; } };
t.equal(stringify(obj), '{"one":1}' );
});
test('toJSON returns string', function (t) {
t.plan(1);
var obj = { one: 1, two: 2, toJSON: function() { return 'one'; } };
t.equal(stringify(obj), '"one"');
});
test('toJSON returns array', function (t) {
t.plan(1);
var obj = { one: 1, two: 2, toJSON: function() { return ['one']; } };
t.equal(stringify(obj), '["one"]');
});