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.

str.js 758B

1234567891011121314151617181920212223242526272829303132
  1. var test = require('tape');
  2. var stringify = require('../');
  3. test('simple object', function (t) {
  4. t.plan(1);
  5. var obj = { c: 6, b: [4,5], a: 3, z: null };
  6. t.equal(stringify(obj), '{"a":3,"b":[4,5],"c":6,"z":null}');
  7. });
  8. test('object with undefined', function (t) {
  9. t.plan(1);
  10. var obj = { a: 3, z: undefined };
  11. t.equal(stringify(obj), '{"a":3}');
  12. });
  13. test('array with undefined', function (t) {
  14. t.plan(1);
  15. var obj = [4, undefined, 6];
  16. t.equal(stringify(obj), '[4,null,6]');
  17. });
  18. test('object with empty string', function (t) {
  19. t.plan(1);
  20. var obj = { a: 3, z: '' };
  21. t.equal(stringify(obj), '{"a":3,"z":""}');
  22. });
  23. test('array with empty string', function (t) {
  24. t.plan(1);
  25. var obj = [4, '', 6];
  26. t.equal(stringify(obj), '[4,"",6]');
  27. });