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

Commit

Permalink
test(dialog): Adding test coverage for ARIA
Browse files Browse the repository at this point in the history
Closes #236
  • Loading branch information
Marcy Sutton authored and ThomasBurleson committed Sep 5, 2014
1 parent fe054ae commit 761ef08
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/components/dialog/demo1/my-dialog.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<material-dialog>
<material-dialog aria-label="Bluth's Original Frozen Banana Stand">
<div class="dialog-content">
<p>A banana is an edible fruit produced by several kinds of large herbaceous flowering plants in the genus Musa. (In some countries, bananas used for cooking may be called plantains.) The fruit is variable in size, color and firmness, but is usually elongated and curved, with soft flesh rich in starch covered with a rind which may be green, yellow, red, purple, or brown when ripe. The fruits grow in clusters hanging from the top of the plant. Almost all modern edible parthenocarpic (seedless) bananas come from two wild species - acuminata and Musa balbisiana. The scientific names of most cultivated bananas are Musa acuminata + Musa balbisiana, and Musa + paradisiaca for the hybrid Musa acuminata balbisiana, depending on their genomic constitution. The old scientific name Musa sapientum is no longer used.

Expand Down
62 changes: 46 additions & 16 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ describe('$materialDialog', function() {
expect(container.length).toBe(1);
}));

it('should have valid ARIA attributes', inject(function($materialDialog, $rootScope) {
var template = '<material-dialog>Hello</material-dialog>';
var parent = angular.element('<div>');

$materialDialog({
template: template,
appendTo: parent
});

$rootScope.$apply();

var dialog = parent.find('material-dialog');
expect(dialog.attr('role')).toBe('dialog');
expect(dialog.attr('aria-label')).toEqual(dialog.text());
}));

it('should escapeToClose == true', inject(function($materialDialog, $rootScope, $rootElement, $timeout, $materialEffects) {
var parent = angular.element('<div>');
$materialDialog({
Expand Down Expand Up @@ -209,4 +193,50 @@ describe('$materialDialog', function() {
expect(parent.find('material-dialog.one').length).toBe(0);
expect(parent.find('material-dialog.two').length).toBe(1);
}));

it('should have the dialog role', inject(function($materialDialog, $rootScope) {
var template = '<material-dialog>Hello</material-dialog>';
var parent = angular.element('<div>');

$materialDialog({
template: template,
appendTo: parent
});

$rootScope.$apply();

var dialog = parent.find('material-dialog');
expect(dialog.attr('role')).toBe('dialog');
}));

it('should create an ARIA label if one is missing', inject(function($materialDialog, $rootScope) {
var template = '<material-dialog>Hello</material-dialog>';
var parent = angular.element('<div>');

$materialDialog({
template: template,
appendTo: parent
});

$rootScope.$apply();

var dialog = parent.find('material-dialog');
expect(dialog.attr('aria-label')).toEqual(dialog.text());
}));

it('should not modify an existing ARIA label', inject(function($materialDialog, $rootScope){
var template = '<material-dialog aria-label="Some Other Thing">Hello</material-dialog>';
var parent = angular.element('<div>');

$materialDialog({
template: template,
appendTo: parent
});

$rootScope.$apply();

var dialog = parent.find('material-dialog');
expect(dialog.attr('aria-label')).not.toEqual(dialog.text());
expect(dialog.attr('aria-label')).toEqual('Some Other Thing');
}));
});

0 comments on commit 761ef08

Please sign in to comment.