This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mdAria): Checks child nodes for aria-label
Closes #567
- Loading branch information
Marcy Sutton
committed
Nov 19, 2014
1 parent
768cc09
commit 9995e6d
Showing
2 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
describe('$mdAria service', function() { | ||
beforeEach(module('material.core')); | ||
|
||
describe('expecting attributes', function(){ | ||
it('should warn if element is missing text', inject(function($compile, $rootScope, $log, $mdAria) { | ||
spyOn($log, 'warn'); | ||
var button = $compile('<button><md-icon></md-icon></button>')($rootScope); | ||
|
||
$mdAria.expect(button, 'aria-label'); | ||
|
||
expect($log.warn).toHaveBeenCalled(); | ||
})); | ||
|
||
it('should not warn if child element has attribute', inject(function($compile, $rootScope, $log, $mdAria) { | ||
spyOn($log, 'warn'); | ||
var button = $compile('<button><md-icon aria-label="text"></md-icon></button>')($rootScope); | ||
|
||
$mdAria.expect(button, 'aria-label'); | ||
|
||
expect($log.warn).not.toHaveBeenCalled(); | ||
})); | ||
|
||
it('should warn if child with attribute is hidden', inject(function($compile, $rootScope, $log, $mdAria) { | ||
spyOn($log, 'warn'); | ||
var container = angular.element(document.body); | ||
var button = $compile('<button><md-icon aria-label="text" style="display:none;"></md-icon></button>')($rootScope); | ||
|
||
container.append(button); | ||
|
||
$mdAria.expect(button, 'aria-label'); | ||
|
||
expect($log.warn).toHaveBeenCalled(); | ||
|
||
button.remove(); | ||
|
||
})); | ||
}); | ||
|
||
}); |