2018-08-09 23:25:55 -07:00
|
|
|
import { module, test } from 'qunit';
|
|
|
|
|
import { setupTest } from 'ember-qunit';
|
2018-05-01 11:37:30 -07:00
|
|
|
|
2018-08-09 23:25:55 -07:00
|
|
|
module('Unit | Service | banners', function(hooks) {
|
|
|
|
|
setupTest(hooks);
|
2018-05-01 11:37:30 -07:00
|
|
|
|
2018-08-09 23:25:55 -07:00
|
|
|
test('it exists', function(assert) {
|
|
|
|
|
const service = this.owner.lookup('service:banners');
|
|
|
|
|
assert.ok(service, 'Existence is a good start');
|
|
|
|
|
});
|
2018-05-01 11:37:30 -07:00
|
|
|
|
2018-08-09 23:25:55 -07:00
|
|
|
test('it operates correctly', async function(assert) {
|
|
|
|
|
const service = this.owner.lookup('service:banners');
|
|
|
|
|
const message = 'Ash Ketchum from Pallet Town';
|
2018-05-01 11:37:30 -07:00
|
|
|
|
2018-08-09 23:25:55 -07:00
|
|
|
service.addBanner('Ash Ketchum from Pallet Town', 'info');
|
2018-05-01 11:37:30 -07:00
|
|
|
|
2018-08-09 23:25:55 -07:00
|
|
|
assert.equal(service.banners.length, 1, 'Created a banner');
|
|
|
|
|
assert.equal(service.banners[0].content, message, 'Creates a banner with the right message');
|
|
|
|
|
assert.equal(service.banners[0].isDismissable, true, 'Creates a banner with the right dismiss');
|
2018-05-01 11:37:30 -07:00
|
|
|
|
2018-08-09 23:25:55 -07:00
|
|
|
await service.dequeue().then(() => {
|
|
|
|
|
assert.equal(service.banners.length, 0, 'Removes a banner correctly');
|
|
|
|
|
});
|
2018-05-01 11:37:30 -07:00
|
|
|
});
|
|
|
|
|
});
|