Ghost/ghost/admin/tests/unit/serializers/notification-test.js

44 lines
1.3 KiB
JavaScript
Raw Normal View History

import Pretender from 'pretender';
import ghostPaths from 'ghost-admin/utils/ghost-paths';
2016-11-24 01:50:57 +03:00
import {describe, it} from 'mocha';
import {expect} from 'chai';
import {setupTest} from 'ember-mocha';
2016-11-24 01:50:57 +03:00
describe('Unit: Serializer: notification', function () {
setupTest();
2016-11-24 01:50:57 +03:00
let server;
2016-11-24 01:50:57 +03:00
beforeEach(function () {
server = new Pretender();
});
2016-11-24 01:50:57 +03:00
afterEach(function () {
server.shutdown();
});
2016-11-24 01:50:57 +03:00
it('converts location->key when deserializing', function () {
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-11-24 01:50:57 +03:00
return [200, {'Content-Type': 'application/json'}, JSON.stringify(response)];
});
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-11-24 01:50:57 +03:00
});
});