@@ -5,20 +5,17 @@ describe('Gallery', function () {
5
5
6
6
describe ( '#start' , function ( ) {
7
7
var itemElem1 , itemElem2 , items , galleryElem ;
8
- var MockItem = function ( hasLabel ) {
8
+ var MockItem = function ( hasLabel , attributes ) {
9
9
this . hasLabel = hasLabel ;
10
+ this . attributes = attributes ;
10
11
return this ;
11
12
} ;
12
13
MockItem . prototype . querySelector = function ( selector ) {
13
14
if ( selector === "label" ) {
14
15
return this . hasLabel ;
15
16
} else if ( selector === "img" ) {
16
17
return {
17
- attributes : {
18
- alt : {
19
- value : "ALT"
20
- }
21
- }
18
+ attributes : this . attributes
22
19
} ;
23
20
}
24
21
} ;
@@ -27,8 +24,8 @@ describe('Gallery', function () {
27
24
28
25
beforeEach ( function ( ) {
29
26
/* Mock Item elements */
30
- itemElem1 = new MockItem ( true ) ;
31
- itemElem2 = new MockItem ( false ) ;
27
+ itemElem1 = new MockItem ( true , { } ) ;
28
+ itemElem2 = new MockItem ( false , { alt : { value : "ALT" } } ) ;
32
29
items = [ itemElem1 , itemElem2 ] ;
33
30
/* Mock DOM Gallery element */
34
31
galleryElem = {
@@ -77,6 +74,13 @@ describe('Gallery', function () {
77
74
appendChildSpy1 . restore ( ) ;
78
75
appendChildSpy2 . restore ( ) ;
79
76
} ) ;
77
+ it ( "doesn't fail if items doesn't have an alt attribute" , function ( ) {
78
+ delete itemElem2 . attributes . alt ;
79
+ var appendChildSpy2 = sinon . spy ( itemElem2 , "appendChild" ) ;
80
+ Gallery . start ( galleryElem ) ;
81
+ expect ( appendChildSpy2 . called ) . to . be . false ;
82
+ appendChildSpy2 . restore ( ) ;
83
+ } ) ;
80
84
} ) ;
81
85
describe ( '#step' , function ( ) {
82
86
var items ;
0 commit comments