@@ -7,15 +7,11 @@ define([
77 'velocity' ,
88 'bellows'
99] , function ( fixture , items , item , disabledItem , $ ) {
10- var element ;
10+ var $ element;
1111
1212 describe ( 'Bellows plugin' , function ( ) {
1313 beforeEach ( function ( ) {
14- element = $ ( fixture ) . appendTo ( '#container' ) ;
15- } ) ;
16-
17- afterEach ( function ( ) {
18- element = null ;
14+ $element = $ ( fixture ) . appendTo ( '#container' ) ;
1915 } ) ;
2016
2117 describe ( 'binding to Zepto\'s fn' , function ( ) {
@@ -33,123 +29,135 @@ define([
3329 } ) ;
3430
3531 describe ( 'invoking bellows' , function ( ) {
36- it ( 'creates bellows instance on element' , function ( ) {
37- element . bellows ( ) ;
32+ afterEach ( function ( ) {
33+ $element . bellows ( 'destroy' ) ;
34+ } ) ;
35+
36+ it ( 'creates bellows instance on $element' , function ( ) {
37+ $element . bellows ( ) ;
3838
39- assert . isDefined ( element . data ( 'bellows' ) ) ;
39+ assert . isDefined ( $ element. data ( 'bellows' ) ) ;
4040 } ) ;
4141
42- it ( 'stores element inside instance' , function ( ) {
43- element . bellows ( ) ;
42+ it ( 'stores $ element inside instance' , function ( ) {
43+ $ element. bellows ( ) ;
4444
45- assert . isDefined ( element . data ( 'bellows' ) . $bellows ) ;
45+ assert . isDefined ( $ element. data ( 'bellows' ) . $bellows ) ;
4646 } ) ;
4747
4848 it ( 'wraps each content section with correct CSS class' , function ( ) {
49- element . bellows ( ) ;
49+ $ element. bellows ( ) ;
5050
51- assert . lengthOf ( element . find ( '.bellows__content-wrapper' ) , 2 ) ;
51+ assert . lengthOf ( $ element. find ( '.bellows__content-wrapper' ) , 2 ) ;
5252 } ) ;
5353 } ) ;
5454
5555 describe ( 'invoking bellows methods before plugin is initialized' , function ( ) {
5656 it ( 'throws when not initialized' , function ( ) {
57- assert . throws ( function ( ) { element . bellows ( 'open' ) ; } ) ;
57+ assert . throws ( function ( ) { $ element. bellows ( 'open' ) ; } ) ;
5858 } ) ;
5959 } ) ;
6060
6161 describe ( 'invoking bellows methods using the plugin interface' , function ( ) {
62+ afterEach ( function ( ) {
63+ $element . bellows ( 'destroy' ) ;
64+ } ) ;
65+
6266 it ( 'opens a bellows item using the open method' , function ( done ) {
63- element . bellows ( {
67+ $ element. bellows ( {
6468 opened : function ( e , ui ) {
6569 assert . isTrue ( ui . item . hasClass ( 'bellows--is-open' ) ) ;
6670 done ( ) ;
6771 }
6872 } ) ;
6973
70- element . bellows ( 'open' , 0 ) ;
74+ $ element. bellows ( 'open' , 0 ) ;
7175 } ) ;
7276
7377 it ( 'closes a bellows item using the close method' , function ( done ) {
74- element . bellows ( {
78+ $ element. bellows ( {
7579 opened : function ( ) {
76- element . bellows ( 'close' , 0 ) ;
80+ $ element. bellows ( 'close' , 0 ) ;
7781 } ,
7882 closed : function ( e , ui ) {
7983 assert . isFalse ( ui . item . hasClass ( 'bellows--is-open' ) ) ;
8084 done ( ) ;
8185 }
8286 } ) ;
8387
84- element . bellows ( 'open' , 0 ) ;
88+ $ element. bellows ( 'open' , 0 ) ;
8589 } ) ;
8690
8791 it ( 'removes aria-hidden attribute when open' , function ( done ) {
88- element . bellows ( {
92+ $ element. bellows ( {
8993 opened : function ( e , ui ) {
9094 assert . isFalse ( ! ! ui . item . find ( '.bellows__content-wrapper' ) . attr ( 'aria-hidden' ) ) ;
9195 done ( ) ;
9296 }
9397 } ) ;
9498
95- element . bellows ( 'open' , 0 ) ;
99+ $ element. bellows ( 'open' , 0 ) ;
96100 } ) ;
97101
98102 it ( 'adds aria-hidden attribute when closed' , function ( done ) {
99- element . bellows ( {
103+ $ element. bellows ( {
100104 opened : function ( ) {
101- element . bellows ( 'close' , 0 ) ;
105+ $ element. bellows ( 'close' , 0 ) ;
102106 } ,
103107 closed : function ( e , ui ) {
104108 assert . isTrue ( ! ! ui . item . find ( '.bellows__content-wrapper' ) . attr ( 'aria-hidden' ) ) ;
105109 done ( ) ;
106110 }
107111 } ) ;
108112
109- element . bellows ( 'open' , 0 ) ;
113+ $ element. bellows ( 'open' , 0 ) ;
110114 } ) ;
111115
112116 it ( 'enables handlers for dynamically added items' , function ( done ) {
113- element . bellows ( {
117+ $ element. bellows ( {
114118 open : function ( ) {
115119 done ( ) ;
116120 }
117121 } ) ;
118122
119- element
123+ $ element
120124 . bellows ( 'add' , items )
121125 . find ( '.bellows__header:eq(3)' )
122126 . trigger ( 'click' ) ;
123127 } ) ;
124128
125129 it ( 'replaces items when adding with replace' , function ( ) {
126- element . bellows ( ) ;
130+ $ element. bellows ( ) ;
127131
128- element . bellows ( 'add' , item , true ) ;
132+ $ element. bellows ( 'add' , item , true ) ;
129133
130- assert . equal ( element . find ( '.bellows__item' ) . length , 1 ) ;
134+ assert . equal ( $ element. find ( '.bellows__item' ) . length , 1 ) ;
131135 } ) ;
132136
133137 it ( 'throws for method calls that don\'t exist' , function ( ) {
134- assert . throws ( function ( ) { element . bellows ( ) . bellows ( 'noMethod' ) ; } ) ;
138+ assert . throws ( function ( ) { $ element. bellows ( ) . bellows ( 'noMethod' ) ; } ) ;
135139 } ) ;
136140
137141 it ( 'throws when attempting to invoke private methods' , function ( ) {
138- assert . throws ( function ( ) { element . bellows ( ) . bellows ( '_init' ) ; } ) ;
142+ assert . throws ( function ( ) { $ element. bellows ( ) . bellows ( '_init' ) ; } ) ;
139143 } ) ;
140144
141145 it ( 'throws when attempting to invoke methods that aren\'t functions' , function ( ) {
142- assert . throws ( function ( ) { element . bellows ( ) . bellows ( 'singleItemOpen' ) ; } ) ;
146+ assert . throws ( function ( ) { $ element. bellows ( ) . bellows ( 'singleItemOpen' ) ; } ) ;
143147 } ) ;
144148 } ) ;
145149
146150 describe ( 'disabling a bellows item' , function ( ) {
151+ afterEach ( function ( ) {
152+ $element . bellows ( 'destroy' ) ;
153+ } ) ;
154+
147155 it ( 'does not open item when header clicked' , function ( done ) {
148- element . bellows ( ) ;
156+ $ element. bellows ( ) ;
149157
150158 var $disabledItem = $ ( disabledItem ) ;
151159
152- element . bellows ( 'add' , $disabledItem ) ;
160+ $ element. bellows ( 'add' , $disabledItem ) ;
153161
154162 $disabledItem
155163 . find ( '.bellows__header' )
0 commit comments