Skip to content

Commit 33067ae

Browse files
committed
test(modal): Add test for double close/dismiss fix #260
1 parent 24e4737 commit 33067ae

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/modal/test/modal.spec.js

+31
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,37 @@ describe('$modal', function () {
188188
expect($document).not.toHaveBackdrop();
189189
});
190190

191+
it('should not throw an exception on a second dismiss', function () {
192+
var modal = open({template: '<div>Content</div>'});
193+
194+
expect($document).toHaveModalsOpen(1);
195+
expect($document).toHaveModalOpenWithContent('Content', 'div');
196+
expect($document).toHaveBackdrop();
197+
198+
dismiss(modal, 'closing in test');
199+
200+
expect($document).toHaveModalsOpen(0);
201+
202+
dismiss(modal, 'closing in test');
203+
});
204+
205+
it('should not throw an exception on a second close', function () {
206+
207+
var modal = open({template: '<div>Content</div>'});
208+
209+
expect($document).toHaveModalsOpen(1);
210+
expect($document).toHaveModalOpenWithContent('Content', 'div');
211+
expect($document).toHaveBackdrop();
212+
213+
modal.close('closing in test');
214+
$timeout.flush();
215+
$rootScope.$digest();
216+
217+
expect($document).toHaveModalsOpen(0);
218+
219+
modal.close('closing in test');
220+
});
221+
191222
it('should open a modal from templateUrl', function () {
192223

193224
$templateCache.put('content.html', '<div>URL Content</div>');

0 commit comments

Comments
 (0)