-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathariaRequired.spec.js
58 lines (52 loc) · 1.99 KB
/
ariaRequired.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
describe('ariaRequiredAttr', function(){
var validTmpl = "<input required>"+
"<textarea required></textarea>"+
"<button required></button>"+
"<select required></select>";
var invalidTmpl = "<input>"+
"<textarea></textarea>"+
"<button></button>"+
"<select></select>";
describe('basic', function(){
setupModule();
it('should apply the attribute when requried is set', inject(function($rootScope, $compile){
element = $compile(validTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', 'true');
}));
it('should not apply the attribute when requried is not set', inject(function($rootScope, $compile){
element = $compile(invalidTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', 'false');
}));
});
describe('dynamic', function(){
setupModule();
it('should go from true to false when the attribute is removed', inject(function($rootScope, $compile){
element = $compile(validTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', 'true');
element = $compile(invalidTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', 'false');
}));
it('should go from false to true when the attribute is removed', inject(function($rootScope, $compile){
element = $compile(invalidTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', 'false');
element = $compile(validTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', 'true');
}));
});
describe('disabled', function(){
setupModule({
ariaRequired: false
});
it('should not set the attributes when it is not enabled in the config', inject(function($rootScope, $compile){
element = $compile(validTmpl)($rootScope);
$rootScope.$digest();
expectAriaAttr('aria-required', undefined);
}));
});
});