Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

to-json.js 607B

12345678910111213141516171819202122
  1. 'use strict';
  2. var test = require('tape');
  3. var stringify = require('../');
  4. test('toJSON function', function (t) {
  5. t.plan(1);
  6. var obj = { one: 1, two: 2, toJSON: function() { return { one: 1 }; } };
  7. t.equal(stringify(obj), '{"one":1}' );
  8. });
  9. test('toJSON returns string', function (t) {
  10. t.plan(1);
  11. var obj = { one: 1, two: 2, toJSON: function() { return 'one'; } };
  12. t.equal(stringify(obj), '"one"');
  13. });
  14. test('toJSON returns array', function (t) {
  15. t.plan(1);
  16. var obj = { one: 1, two: 2, toJSON: function() { return ['one']; } };
  17. t.equal(stringify(obj), '["one"]');
  18. });