|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
574 bytes
|
| Line | |
|---|
| 1 | var test = require('tape');
|
|---|
| 2 | var stringify = require('../');
|
|---|
| 3 |
|
|---|
| 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 |
|
|---|
| 10 | test('toJSON returns string', function (t) {
|
|---|
| 11 | t.plan(1);
|
|---|
| 12 | var obj = { one: 1, two: 2, toJSON: function() { return 'one'; } };
|
|---|
| 13 | t.equal(stringify(obj), '"one"');
|
|---|
| 14 | });
|
|---|
| 15 |
|
|---|
| 16 | test('toJSON returns array', function (t) {
|
|---|
| 17 | t.plan(1);
|
|---|
| 18 | var obj = { one: 1, two: 2, toJSON: function() { return ['one']; } };
|
|---|
| 19 | t.equal(stringify(obj), '["one"]');
|
|---|
| 20 | });
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.