2016-11-24 01:50:57 +03:00
|
|
|
import {describe, it} from 'mocha';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {expect} from 'chai';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {setupTest} from 'ember-mocha';
|
2016-09-26 16:04:20 +03:00
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
describe('Unit: Transform: json-string', function () {
|
2019-05-13 15:43:53 +03:00
|
|
|
setupTest();
|
2016-09-26 16:04:20 +03:00
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
it('serialises an Object to a JSON String', function () {
|
2019-05-13 15:43:53 +03:00
|
|
|
let transform = this.owner.lookup('transform:json-string');
|
2016-11-24 01:50:57 +03:00
|
|
|
let obj = {one: 'one', two: 'two'};
|
|
|
|
expect(transform.serialize(obj)).to.equal(JSON.stringify(obj));
|
|
|
|
});
|
2016-09-26 16:04:20 +03:00
|
|
|
|
2018-01-05 18:38:23 +03:00
|
|
|
it('deserialises a JSON String to an Object', function () {
|
2019-05-13 15:43:53 +03:00
|
|
|
let transform = this.owner.lookup('transform:json-string');
|
2016-11-24 01:50:57 +03:00
|
|
|
let obj = {one: 'one', two: 'two'};
|
|
|
|
expect(transform.deserialize(JSON.stringify(obj))).to.deep.equal(obj);
|
|
|
|
});
|
2017-08-29 06:03:45 +03:00
|
|
|
|
|
|
|
it('handles deserializing a blank string', function () {
|
2019-05-13 15:43:53 +03:00
|
|
|
let transform = this.owner.lookup('transform:json-string');
|
2017-08-29 06:03:45 +03:00
|
|
|
expect(transform.deserialize('')).to.equal(null);
|
|
|
|
});
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|