2017-05-29 21:50:03 +03:00
|
|
|
import Pretender from 'pretender';
|
2021-02-05 12:12:26 +03:00
|
|
|
import ghostPaths from 'ghost-admin/utils/ghost-paths';
|
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';
|
2019-05-13 15:43:53 +03:00
|
|
|
import {setupTest} from 'ember-mocha';
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
describe('Unit: Serializer: notification', function () {
|
2019-05-13 15:43:53 +03:00
|
|
|
setupTest();
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
let server;
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
beforeEach(function () {
|
|
|
|
server = new Pretender();
|
|
|
|
});
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
afterEach(function () {
|
|
|
|
server.shutdown();
|
|
|
|
});
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
it('converts location->key when deserializing', function () {
|
2021-02-05 12:12:26 +03:00
|
|
|
server.get(`${ghostPaths().apiRoot}/notifications`, function () {
|
2016-11-24 01:50:57 +03:00
|
|
|
let response = {
|
|
|
|
notifications: [{
|
|
|
|
id: 1,
|
|
|
|
dismissible: false,
|
|
|
|
status: 'alert',
|
|
|
|
type: 'info',
|
|
|
|
location: 'test.foo',
|
|
|
|
message: 'This is a test'
|
|
|
|
}]
|
|
|
|
};
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
return [200, {'Content-Type': 'application/json'}, JSON.stringify(response)];
|
|
|
|
});
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2019-05-13 15:43:53 +03:00
|
|
|
let store = this.owner.lookup('service:store');
|
|
|
|
|
|
|
|
return store.findAll('notification').then((notifications) => {
|
2016-11-24 01:50:57 +03:00
|
|
|
expect(notifications.get('length')).to.equal(1);
|
|
|
|
expect(notifications.get('firstObject.key')).to.equal('test.foo');
|
2016-09-01 19:01:54 +03:00
|
|
|
});
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|
|
|
|
});
|