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
govuk_publishing_components-17.0.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.29.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.29.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.28.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.28.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.27.1 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.27.1 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.27.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.27.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.26.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.26.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.25.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.25.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.24.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.24.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.23.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.23.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.22.0 node_modules/json-stable-stringify/test/to-json.js
govuk_publishing_components-16.22.0 node_modules/json-stable-stringify-without-jsonify/test/to-json.js
govuk_publishing_components-16.21.0 node_modules/json-stable-stringify/test/to-json.js