@@ -2,39 +2,29 @@ describe('non-empty-alt', function() {
2
2
'use strict' ;
3
3
4
4
var fixture = document . getElementById ( 'fixture' ) ;
5
+ var checkSetup = axe . testUtils . checkSetup ;
5
6
6
7
afterEach ( function ( ) {
7
8
fixture . innerHTML = '' ;
8
9
} ) ;
9
10
10
11
it ( 'should return true if an alt is present' , function ( ) {
11
- var node = document . createElement ( 'img' ) ;
12
- node . setAttribute ( 'alt' , 'woohoo' ) ;
13
- fixture . appendChild ( node ) ;
14
-
15
- assert . isTrue ( checks [ 'non-empty-alt' ] . evaluate ( node ) ) ;
12
+ var params = checkSetup ( '<img id="target" alt="woohoo" />' ) ;
13
+ assert . isTrue ( checks [ 'non-empty-alt' ] . evaluate . apply ( null , params ) ) ;
16
14
} ) ;
17
15
18
16
it ( 'should return false if an alt is not present' , function ( ) {
19
- var node = document . createElement ( 'img' ) ;
20
- fixture . appendChild ( node ) ;
21
-
22
- assert . isFalse ( checks [ 'non-empty-alt' ] . evaluate ( node ) ) ;
17
+ var params = checkSetup ( '<img id="target" />' ) ;
18
+ assert . isFalse ( checks [ 'non-empty-alt' ] . evaluate . apply ( null , params ) ) ;
23
19
} ) ;
24
20
25
21
it ( 'should return false if an alt is present, but empty' , function ( ) {
26
- var node = document . createElement ( 'img' ) ;
27
- node . setAttribute ( 'alt' , ' ' ) ;
28
- fixture . appendChild ( node ) ;
29
-
30
- assert . isFalse ( checks [ 'non-empty-alt' ] . evaluate ( node ) ) ;
22
+ var params = checkSetup ( '<img id="target" alt=" " />' ) ;
23
+ assert . isFalse ( checks [ 'non-empty-alt' ] . evaluate . apply ( null , params ) ) ;
31
24
} ) ;
32
25
33
26
it ( 'should collapse whitespace' , function ( ) {
34
- var node = document . createElement ( 'div' ) ;
35
- node . setAttribute ( 'alt' , ' \t \n \r \t \t\r\n ' ) ;
36
- fixture . appendChild ( node ) ;
37
-
38
- assert . isFalse ( checks [ 'non-empty-alt' ] . evaluate ( node ) ) ;
27
+ var params = checkSetup ( '<img id="target" alt=" \t \n \r \t \t\r\n " />' ) ;
28
+ assert . isFalse ( checks [ 'non-empty-alt' ] . evaluate . apply ( null , params ) ) ;
39
29
} ) ;
40
30
} ) ;
0 commit comments