Newer
Older
CVSS_3.0_GUI / dist / CVSS_3.0_Calc-1.0.0-linux-x64 / node_modules / nwjs-builder-phoenix / node_modules / request / node_modules / har-validator / node_modules / ajv / node_modules / fast-json-stable-stringify / test / to-json.js
root on 7 May 2019 607 bytes Initial commit
  1. 'use strict';
  2.  
  3. var test = require('tape');
  4. var stringify = require('../');
  5.  
  6. test('toJSON function', function (t) {
  7. t.plan(1);
  8. var obj = { one: 1, two: 2, toJSON: function() { return { one: 1 }; } };
  9. t.equal(stringify(obj), '{"one":1}' );
  10. });
  11.  
  12. test('toJSON returns string', function (t) {
  13. t.plan(1);
  14. var obj = { one: 1, two: 2, toJSON: function() { return 'one'; } };
  15. t.equal(stringify(obj), '"one"');
  16. });
  17.  
  18. test('toJSON returns array', function (t) {
  19. t.plan(1);
  20. var obj = { one: 1, two: 2, toJSON: function() { return ['one']; } };
  21. t.equal(stringify(obj), '["one"]');
  22. });
Buy Me A Coffee