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

44 lines
1.3 KiB
JavaScript
Raw Normal View History

import Pretender from 'pretender';
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 {setupModelTest} from 'ember-mocha';
2016-11-24 01:50:57 +03:00
describe('Unit: Serializer: notification', function () {
setupModelTest('notification', {
// Specify the other units that are required for this test.
needs: ['serializer:notification']
2016-11-24 01:50:57 +03:00
});
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('/notifications', function () {
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)];
});
2016-11-24 01:50:57 +03:00
return this.store().findAll('notification').then((notifications) => {
expect(notifications.get('length')).to.equal(1);
expect(notifications.get('firstObject.key')).to.equal('test.foo');
});
2016-11-24 01:50:57 +03:00
});
});