Fixed failing tests

This commit is contained in:
Henry 2015-10-14 12:31:21 -07:00
parent ee382be38d
commit 1d41939418
4 changed files with 41 additions and 17 deletions

View File

@ -71,6 +71,9 @@ define(
* @param {object} overlayModel the model to pass to the
* included overlay template (this will be passed
* in via ng-model)
* @param {string} typeClass the element class to use in rendering
* the overlay. Can be specified to provide custom styling of
* overlays
*/
OverlayService.prototype.createOverlay = function (key, overlayModel, typeClass) {
// Create a new scope for this overlay
@ -87,13 +90,10 @@ define(
// If no model is supplied, just fill in a default "cancel"
overlayModel = overlayModel || { cancel: dismiss };
// If no typeClass is specified, set to default "t-dialog"
typeClass = typeClass || 't-dialog';
// Populate the scope; will be passed directly to the template
scope.overlay = overlayModel;
scope.key = key;
scope.typeClass = typeClass;
scope.typeClass = typeClass || 't-dialog';
// Create the overlay element and add it to the document's body
element = this.$compile(TEMPLATE)(scope);

View File

@ -116,7 +116,8 @@ define(
dialog: dialogModel,
confirm: jasmine.any(Function),
cancel: jasmine.any(Function)
}
},
't-dialog'
);
});

View File

@ -176,18 +176,14 @@ define(
timeout;
this.active.notification = notification;
/*
If autoDismiss has been specified, setup a timeout to
dismiss the dialog.
If there are other notifications pending in the queue, set this
one to auto-dismiss
If autoDismiss has been specified, OR there are other
notifications queued for display, setup a timeout to
dismiss the dialog.
*/
if (notification && (notification.autoDismiss
if (notification && (notification.autoDismiss !== false
|| this.selectNextNotification())) {
timeout = notification.autoDismiss ?
notification.autoDismiss :
this.DEFAULT_AUTO_DISMISS;
timeout = notification.autoDismiss || this.DEFAULT_AUTO_DISMISS;
this.active.timeout = this.$timeout(function () {
self.dismissOrMinimize(notification);
}, timeout);

View File

@ -30,6 +30,7 @@ define(
var notificationService,
mockTimeout,
mockAutoDismiss,
mockMinimizeTimeout,
successModel,
errorModel;
@ -75,9 +76,9 @@ define(
beforeEach(function(){
mockTimeout = jasmine.createSpy("$timeout");
mockAutoDismiss = 0;
mockAutoDismiss = mockMinimizeTimeout = 1000;
notificationService = new NotificationService(
mockTimeout, mockAutoDismiss);
mockTimeout, mockAutoDismiss, mockMinimizeTimeout);
successModel = {
title: "Mock Success Notification",
severity: MessageSeverity.INFO
@ -104,6 +105,8 @@ define(
activeNotification = notificationService.getActiveNotification();
expect(activeNotification).toBe(successModel);
mockTimeout.mostRecentCall.args[0]();
expect(mockTimeout.calls.length).toBe(2);
mockTimeout.mostRecentCall.args[0]();
activeNotification = notificationService.getActiveNotification();
expect(activeNotification).toBeUndefined();
});
@ -116,6 +119,8 @@ define(
activeNotification = notificationService.getActiveNotification();
expect(activeNotification).toBe(successModel);
mockTimeout.mostRecentCall.args[0]();
expect(mockTimeout.calls.length).toBe(2);
mockTimeout.mostRecentCall.args[0]();
activeNotification = notificationService.getActiveNotification();
expect(activeNotification).toBeUndefined();
});
@ -135,9 +140,15 @@ define(
//But it should be auto-dismissed and replaced with the
// error notification
mockTimeout.mostRecentCall.args[0]();
//Two timeouts, one is to force minimization after
// displaying the message for a minimum period, the
// second is to allow minimization animation to take place.
mockTimeout.mostRecentCall.args[0]();
activeNotification = notificationService.getActiveNotification();
expect(activeNotification).toBe(errorModel);
});
/* Test is temporarily invalid as info messages are being
minimized
it("auto-dismisses an active success notification, removing" +
" it completely", function() {
//First pre-load with a info message
@ -146,9 +157,13 @@ define(
notificationService.notify(errorModel);
expect(notificationService.notifications.length).toEqual(2);
mockTimeout.mostRecentCall.args[0]();
//Two timeouts, one is to force minimization after
// displaying the message for a minimum period, the
// second is to allow minimization animation to take place.
mockTimeout.mostRecentCall.args[0]();
//Previous info message should be completely dismissed
expect(notificationService.notifications.length).toEqual(1);
});
});*/
it("auto-minimizes an active error notification", function() {
var activeNotification;
//First pre-load with an error message
@ -158,6 +173,10 @@ define(
expect(notificationService.notifications.length).toEqual(2);
//Mock the auto-minimize
mockTimeout.mostRecentCall.args[0]();
//Two timeouts, one is to force minimization after
// displaying the message for a minimum period, the
// second is to allow minimization animation to take place.
mockTimeout.mostRecentCall.args[0]();
//Previous error message should be minimized, not
// dismissed
expect(notificationService.notifications.length).toEqual(2);
@ -186,6 +205,10 @@ define(
expect(notificationService.notifications.length).toEqual(3);
//Mock the auto-minimize
mockTimeout.mostRecentCall.args[0]();
//Two timeouts, one is to force minimization after
// displaying the message for a minimum period, the
// second is to allow minimization animation to take place.
mockTimeout.mostRecentCall.args[0]();
//Previous error message should be minimized, not
// dismissed
expect(notificationService.notifications.length).toEqual(3);
@ -196,6 +219,10 @@ define(
//Mock the second auto-minimize
mockTimeout.mostRecentCall.args[0]();
//Two timeouts, one is to force minimization after
// displaying the message for a minimum period, the
// second is to allow minimization animation to take place.
mockTimeout.mostRecentCall.args[0]();
activeNotification =
notificationService.getActiveNotification();
expect(activeNotification).toBe(error3);