Ghost/ghost/admin/tests/unit/transforms/json-string-test.js

25 lines
896 B
JavaScript
Raw Normal View History

2016-11-24 01:50:57 +03:00
import {describe, it} from 'mocha';
import {expect} from 'chai';
2016-11-24 01:50:57 +03:00
import {setupTest} from 'ember-mocha';
describe('Unit: Transform: json-string', function () {
setupTest();
it('serialises an Object to a JSON String', function () {
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));
});
it('deserialises a JSON String to an Object', function () {
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);
});
it('handles deserializing a blank string', function () {
let transform = this.owner.lookup('transform:json-string');
expect(transform.deserialize('')).to.equal(null);
});
2016-11-24 01:50:57 +03:00
});