diff --git a/src/directives/toast/toast.directive.js b/src/directives/toast/toast.directive.js index 43e1a4b..bbd6b5c 100644 --- a/src/directives/toast/toast.directive.js +++ b/src/directives/toast/toast.directive.js @@ -28,7 +28,7 @@ var button = angular.element(scope.options.closeHtml), $compile = $injector.get('$compile'); button.addClass('toast-close-button'); - button.attr('ng-click', 'close()'); + button.attr('ng-click', 'close(true)'); $compile(button)(scope); element.prepend(button); } diff --git a/test/toastr_spec.js b/test/toastr_spec.js index cbfb93b..1813a4c 100644 --- a/test/toastr_spec.js +++ b/test/toastr_spec.js @@ -232,6 +232,7 @@ describe('toastr', function() { var toastCloseButton = _findToastCloseButton(noOfToast); toastCloseButton.click(); $rootScope.$digest(); + animationFlush(); } function hoverToast(noOfToast) { @@ -753,6 +754,16 @@ describe('toastr', function() { expect(callback).toHaveBeenCalledWith(true); }); + it('calls the onHidden callback with "true" if the button was clicked', function() { + var callback = jasmine.createSpy(); + openToast('info', 'I have a button', { + onHidden: callback, + closeButton: true + }); + clickToastCloseButton(); + expect(callback).toHaveBeenCalledWith(true); + }); + it('can call the callbacks even if the title is set to null', function() { var callback = jasmine.createSpy(); openToast('success', 'some message', null, {onShown: callback});