2017-05-29 21:50:03 +03:00
|
|
|
import Pretender from 'pretender';
|
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';
|
2016-11-24 01:50:57 +03:00
|
|
|
import {setupModelTest} from 'ember-mocha';
|
2016-09-01 19:01:54 +03:00
|
|
|
|
2016-11-24 01:50:57 +03:00
|
|
|
describe('Unit: Serializer: notification', function () {
|
|
|
|
setupModelTest('notification', {
|
2016-09-01 19:01:54 +03:00
|
|
|
// Specify the other units that are required for this test.
|
|
|
|
needs: ['serializer:notification']
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|
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 () {
|
|
|
|
server.get('/notifications', function () {
|
|
|
|
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
|
|
|
|
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-09-01 19:01:54 +03:00
|
|
|
});
|
2016-11-24 01:50:57 +03:00
|
|
|
});
|
|
|
|
});
|