Sha256: ebfe070bd31b66bf556526c90640e1880a9cd12549946f2dc140917daa84c222

Contents?: true

Size: 574 Bytes

Versions: 140

Compression:

Stored size: 574 Bytes

Contents

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"]');
});

Version data entries

140 entries across 97 versions & 10 rubygems

Version Path
immosquare-cleaner-0.1.6 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
decidim-0.26.8 packages/eslint-config/node_modules/json-stable-stringify-without-jsonify/test/to-json.js
ilog-0.4.1 node_modules/json-stable-stringify/test/to-json.js
ilog-0.4.0 node_modules/json-stable-stringify/test/to-json.js
ilog-0.3.3 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-18.0.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-18.0.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.21.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.21.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-17.20.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-17.20.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.19.1 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-17.19.1 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.19.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.19.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-17.18.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.18.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-17.17.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-17.17.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-17.16.0 node_modules/json-stable-stringify/test/to-json.js