Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
(test dialog) Added tests for testing dialog double opening.
Browse files Browse the repository at this point in the history
There seems to be a bug which prevents a dialog from being closed
if it's opened while another dialog is shown.
  • Loading branch information
erikogenvik committed Oct 15, 2015
1 parent da35154 commit 06a724f
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,65 @@ describe('$mdDialog', function() {
expect(parent[0].querySelectorAll('md-dialog.two').length).toBe(1);
}));

it('should hide dialog', inject(function($mdDialog, $rootScope, $animate) {
var parent = angular.element('<div>');
$mdDialog.show({
template: '<md-dialog class="one">',
parent: parent
});
runAnimation();

$mdDialog.hide();
runAnimation();

expect(parent[0].querySelectorAll('md-dialog.one').length).toBe(0);
}));

it('should allow opening new dialog after existing without corruption', inject(function($mdDialog, $rootScope, $animate) {
var parent = angular.element('<div>');
$mdDialog.show({
template: '<md-dialog class="one">',
parent: parent
});
runAnimation();
$mdDialog.hide();
runAnimation();

$mdDialog.show({
template: '<md-dialog class="two">',
parent: parent
});
runAnimation();
$mdDialog.hide();
runAnimation();

expect(parent[0].querySelectorAll('md-dialog.one').length).toBe(0);
expect(parent[0].querySelectorAll('md-dialog.two').length).toBe(0);
}));

it('should allow opening new dialog from existing without corruption', inject(function($mdDialog, $rootScope, $animate) {
var parent = angular.element('<div>');
$mdDialog.show({
template: '<md-dialog class="one">',
parent: parent
});
runAnimation();

$mdDialog.show({
template: '<md-dialog class="two">',
parent: parent
});
//First run is for the old dialog being hidden.
runAnimation();
//Second run is for the new dialog being shown.
runAnimation();
$mdDialog.hide();
runAnimation();

expect(parent[0].querySelectorAll('md-dialog.one').length).toBe(0);
expect(parent[0].querySelectorAll('md-dialog.two').length).toBe(0);
}));

it('should have the dialog role', inject(function($mdDialog, $rootScope) {
var template = '<md-dialog>Hello</md-dialog>';
var parent = angular.element('<div>');
Expand Down Expand Up @@ -1117,4 +1176,3 @@ describe('$mdDialog with custom interpolation symbols', function() {
expect(buttons.eq(1).text()).toBe('OK');
}));
});

0 comments on commit 06a724f

Please sign in to comment.