[Notifications] #499 All notifications now dismissable by default.

jslint
This commit is contained in:
Henry
2016-02-05 17:40:04 -08:00
parent 2dd9a16bf3
commit 5292b27e7d
7 changed files with 106 additions and 34 deletions

View File

@@ -32,13 +32,19 @@ define(
mockAutoDismiss,
mockMinimizeTimeout,
successModel,
mockTopicFunction,
mockTopicObject,
errorModel;
beforeEach(function(){
mockTimeout = jasmine.createSpy("$timeout");
mockTopicFunction = jasmine.createSpy("topic");
mockTopicObject = jasmine.createSpyObj("topicObject", ["listen", "notify"]);
mockTopicFunction.andReturn(mockTopicObject);
mockAutoDismiss = mockMinimizeTimeout = 1000;
notificationService = new NotificationService(
mockTimeout, mockAutoDismiss, mockMinimizeTimeout);
mockTimeout, mockTopicFunction, mockAutoDismiss, mockMinimizeTimeout);
successModel = {
title: "Mock Success Notification",
severity: "info"
@@ -57,6 +63,19 @@ define(
expect(activeNotification.model).toBe(successModel);
});
it("notifies listeners on dismissal of notification", function() {
var notification,
dismissListener = jasmine.createSpy("ondismiss");
notification = notificationService.notify(successModel);
notification.onDismiss(dismissListener);
expect(mockTopicObject.listen).toHaveBeenCalled();
notification.dismiss();
expect(mockTopicObject.notify).toHaveBeenCalled();
mockTopicObject.listen.mostRecentCall.args[0]();
expect(dismissListener).toHaveBeenCalled();
});
it("allows specification of an info notification given just a" +
" title, making the notification active", function() {
var activeNotification,