Skip to content

Commit

Permalink
Close button also marks onHidden as clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxandxss committed Aug 29, 2015
1 parent 9c181b3 commit 1d93b26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/directives/toast/toast.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 11 additions & 0 deletions test/toastr_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ describe('toastr', function() {
var toastCloseButton = _findToastCloseButton(noOfToast);
toastCloseButton.click();
$rootScope.$digest();
animationFlush();
}

function hoverToast(noOfToast) {
Expand Down Expand Up @@ -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});
Expand Down

0 comments on commit 1d93b26

Please sign in to comment.