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

Commit 94a233c

Browse files
author
Marcy Sutton
committed
test(): Adding test coverage for $materialAria
1 parent 3dad5ca commit 94a233c

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

src/components/checkbox/checkbox.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ function MaterialCheckboxDirective(inputDirectives, $materialInkRipple, $materia
120120

121121
function render() {
122122
checked = ngModelCtrl.$viewValue;
123-
// element.attr('aria-checked', checked);
124123
if(checked) {
125124
element.addClass(CHECKED_CSS);
126125
} else {

src/components/checkbox/checkbox.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ describe('materialCheckbox', function() {
66
beforeEach(module('ngAria'));
77
beforeEach(TestUtil.mockRaf);
88

9+
it('should warn developers they need a label', inject(function($compile, $rootScope, $log){
10+
spyOn($log, "warn");
11+
var element = $compile('<div>' +
12+
'<material-checkbox ng-model="blue">' +
13+
'</material-checkbox>' +
14+
'</div>')($rootScope);
15+
16+
var cbElements = element.find('material-checkbox');
17+
expect($log.warn).toHaveBeenCalled();
18+
}));
19+
20+
xit('should copy text content to aria-label', inject(function($compile, $rootScope){
21+
var element = $compile('<div>' +
22+
'<material-checkbox ng-model="blue">' +
23+
'Some text' +
24+
'</material-checkbox>' +
25+
'</div>')($rootScope);
26+
27+
var cbElements = element.find('material-checkbox');
28+
expect(cbElements.eq(0).attr('aria-label')).toBe('Some text');
29+
}));
30+
931
it('should set checked css class and aria-checked attributes', inject(function($compile, $rootScope) {
1032
var element = $compile('<div>' +
1133
'<material-checkbox ng-model="blue">' +

src/components/radioButton/radioButton.spec.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe('radioButton', function() {
3232
expect(rbGroupElement.find('material-radio-button').eq(0).attr('role')).toEqual('radio');
3333
}));
3434

35-
it('should set aria attributes', inject(function($compile, $rootScope) {
35+
it('should set aria states', inject(function($compile, $rootScope) {
3636
var element = $compile('<material-radio-group ng-model="color">' +
3737
'<material-radio-button value="blue"></material-radio-button>' +
3838
'<material-radio-button value="green"></material-radio-button>' +
@@ -51,6 +51,26 @@ describe('radioButton', function() {
5151
expect(element.attr('aria-activedescendant')).not.toEqual(rbElements.eq(0).attr('id'));
5252
}));
5353

54+
it('should warn developers they need a label', inject(function($compile, $rootScope, $log){
55+
spyOn($log, "warn");
56+
var element = $compile('<material-radio-group ng-model="color">' +
57+
'<material-radio-button value="blue"></material-radio-button>' +
58+
'<material-radio-button value="green"></material-radio-button>' +
59+
'</material-radio-group>')($rootScope);
60+
61+
expect($log.warn).toHaveBeenCalled();
62+
}));
63+
64+
it('should create an aria label from provided text', inject(function($compile, $rootScope) {
65+
var element = $compile('<material-radio-group ng-model="color">' +
66+
'<material-radio-button value="blue">Blue</material-radio-button>' +
67+
'<material-radio-button value="green">Green</material-radio-button>' +
68+
'</material-radio-group>')($rootScope);
69+
70+
var rbElements = element.find('material-radio-button');
71+
expect(rbElements.eq(0).attr('aria-label')).toEqual('Blue');
72+
}));
73+
5474
it('should be operable via arrow keys', inject(function($compile, $rootScope) {
5575
var element = $compile('<material-radio-group ng-model="color">' +
5676
'<material-radio-button value="blue"></material-radio-button>' +

src/components/slider/slider.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ describe('material-slider', function() {
1212
};
1313
}
1414

15+
// beforeEach(TestUtil.mockRaf);
16+
beforeEach(module('ngAria'));
1517
beforeEach(module('material.components.slider','material.decorators'));
1618

1719
it('should set model on press', inject(function($compile, $rootScope, $timeout) {
@@ -93,4 +95,13 @@ describe('material-slider', function() {
9395
expect($rootScope.model).toBe(100);
9496
}));
9597

98+
xit('should warn developers they need a label', inject(function($compile, $rootScope, $timeout, $log) {
99+
spyOn($log, "warn");
100+
101+
var slider = $compile(
102+
'<material-slider min="100" max="104" step="2" ng-model="model">'
103+
)($rootScope);
104+
105+
expect($log.warn).toHaveBeenCalled();
106+
}));
96107
});

src/services/aria/aria.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ function AriaService($$rAF, $log) {
3232

3333
if (hasDefault) {
3434
defaultValue = String(defaultValue).trim();
35-
// $log.warn(messageTemplate + ' ' + defaultValueTemplate,
36-
// attrName, getTagString(node), attrName, defaultValue);
3735
element.attr(attrName, defaultValue);
3836
} else {
3937
$log.warn(messageTemplate, attrName, getTagString(node));

0 commit comments

Comments
 (0)