@@ -2,23 +2,29 @@ describe('has-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 ) ;
12
+ var checkArgs = checkSetup ( '< img id="target" alt="woohoo" /> ') ;
13
+ assert . isTrue ( checks [ 'has- alt'] . evaluate . apply ( null , checkArgs ) ) ;
14
+ } ) ;
14
15
15
- assert . isTrue ( checks [ 'has-alt' ] . evaluate ( node ) ) ;
16
+ it ( 'should return true if an empty alt is present' , function ( ) {
17
+ var checkArgs = checkSetup ( '<img id="target" alt="" />' ) ;
18
+ assert . isTrue ( checks [ 'has-alt' ] . evaluate . apply ( null , checkArgs ) ) ;
16
19
} ) ;
17
20
18
- it ( 'should return false if an alt is not present' , function ( ) {
19
- var node = document . createElement ( 'img' ) ;
20
- fixture . appendChild ( node ) ;
21
+ it ( 'should return true if a null alt is present' , function ( ) {
22
+ var checkArgs = checkSetup ( '<img id="target" alt />' ) ;
23
+ assert . isTrue ( checks [ 'has-alt' ] . evaluate . apply ( null , checkArgs ) ) ;
24
+ } ) ;
21
25
22
- assert . isFalse ( checks [ 'has-alt' ] . evaluate ( node ) ) ;
26
+ it ( 'should return false if an alt is not present' , function ( ) {
27
+ var checkArgs = checkSetup ( '<img id="target" />' ) ;
28
+ assert . isFalse ( checks [ 'has-alt' ] . evaluate . apply ( null , checkArgs ) ) ;
23
29
} ) ;
24
30
} ) ;
0 commit comments