mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 13:22:39 +03:00
6a9239974f
closes https://github.com/TryGhost/Ghost/issues/9031 - add a default value `unsplash` value to the `setting` model so that Unsplash is activated when the server doesn't return an `unsplash` setting - update the `unsplash-settings` transform to always deserialize or serialize to `{isActive: true}` when the value is blank or not parsable - add acceptance regression test covering API not returning an `unplash` setting - add unit tests for the `unsplash-settings` transform
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import {describe, it} from 'mocha';
|
|
import {expect} from 'chai';
|
|
import {setupTest} from 'ember-mocha';
|
|
|
|
describe('Unit: Transform: unsplash-settings', function () {
|
|
setupTest('transform:unsplash-settings', {
|
|
// Specify the other units that are required for this test.
|
|
// needs: ['transform:foo']
|
|
});
|
|
|
|
it('deserializes to default value when null', function () {
|
|
let serialized = null;
|
|
let result = this.subject().deserialize(serialized);
|
|
expect(result.isActive).to.be.true;
|
|
});
|
|
|
|
it('deserializes to default value when blank string', function () {
|
|
let serialized = '';
|
|
let result = this.subject().deserialize(serialized);
|
|
expect(result.isActive).to.be.true;
|
|
});
|
|
|
|
it('deserializes to default value when invalid JSON', function () {
|
|
let serialized = 'not JSON';
|
|
let result = this.subject().deserialize(serialized);
|
|
expect(result.isActive).to.be.true;
|
|
});
|
|
|
|
it('deserializes valid JSON object', function () {
|
|
let serialized = '{"isActive":false}';
|
|
let result = this.subject().deserialize(serialized);
|
|
expect(result.isActive).to.be.false;
|
|
});
|
|
|
|
it('serializes to JSON string', function () {
|
|
let deserialized = {isActive: false};
|
|
let result = this.subject().serialize(deserialized);
|
|
expect(result).to.equal('{"isActive":false}');
|
|
});
|
|
|
|
it('serializes to default value when blank', function () {
|
|
let deserialized = '';
|
|
let result = this.subject().serialize(deserialized);
|
|
expect(result).to.equal('{"isActive":true}');
|
|
});
|
|
});
|