This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed missing Unsplash icons when API doesn't return an unsplash sett…
…ing (#865) closes TryGhost/Ghost#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
- Loading branch information
1 parent
871a104
commit 92e43b7
Showing
4 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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}'); | ||
}); | ||
}); |