Commit 61273c77 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Add tests to cover events emitted by toast messenger

parent 5eb1ac77
...@@ -84,6 +84,20 @@ describe('ToastMessengerService', () => { ...@@ -84,6 +84,20 @@ describe('ToastMessengerService', () => {
assert.calledOnce(fakeStore.getToastMessage); assert.calledOnce(fakeStore.getToastMessage);
assert.notCalled(fakeStore.updateToastMessage); assert.notCalled(fakeStore.updateToastMessage);
}); });
it('emits "toastMessageAdded" event', () => {
fakeStore.hasToastMessage.returns(false);
const fakeHandler = sinon.stub();
service.on('toastMessageAdded', fakeHandler);
service.success('hooray', {});
assert.calledWith(
fakeHandler,
sinon.match({ message: 'hooray', type: 'success' })
);
});
}); });
describe('#notice', () => { describe('#notice', () => {
...@@ -203,6 +217,21 @@ describe('ToastMessengerService', () => { ...@@ -203,6 +217,21 @@ describe('ToastMessengerService', () => {
assert.calledOnce(fakeStore.removeToastMessage); assert.calledOnce(fakeStore.removeToastMessage);
assert.calledWith(fakeStore.removeToastMessage, 'someid'); assert.calledWith(fakeStore.removeToastMessage, 'someid');
}); });
it('emits "toastMessageDismissed" event', () => {
fakeStore.getToastMessage.returns({
id: 'someid',
type: 'success',
message: 'yay',
isDismissed: false,
});
const fakeHandler = sinon.stub();
service.on('toastMessageDismissed', fakeHandler);
service.dismiss('someid');
assert.calledWith(fakeHandler, 'someid');
});
}); });
context('when the message is delayed', () => { context('when the message is delayed', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment