@@ -160,14 +160,36 @@ describe('basic suite', function() {
160
160
expect ( $ ( '.selectric-wrapper' ) . find ( '.label' ) . find ( 'strong' ) . length ) . toBe ( 1 ) ;
161
161
} ) ;
162
162
163
- it ( 'should have custom option item text' , function ( ) {
164
- select . selectric ( {
165
- optionsItemBuilder : function ( itemData ) {
166
- return '<span>' + itemData . text + '</span>' ;
167
- }
163
+ describe ( 'optionsItemBuilder' , function ( ) {
164
+
165
+ it ( 'should have custom option item text' , function ( ) {
166
+ select . selectric ( {
167
+ optionsItemBuilder : function ( itemData ) {
168
+ return '<span>' + itemData . text + '</span>' ;
169
+ }
170
+ } ) ;
171
+ $ ( '.selectric' ) . click ( ) ;
172
+ expect ( $ ( '.selectric-items' ) . find ( 'li.selected' ) . find ( 'span' ) . length ) . toBe ( 1 ) ;
173
+ } ) ;
174
+
175
+ it ( 'should have element available' , function ( ) {
176
+ select . selectric ( {
177
+ optionsItemBuilder : function ( itemData , element ) {
178
+ element . addClass ( 'testtest' ) ;
179
+ return '<span>' + itemData . text + '</span>' ;
180
+ }
181
+ } ) ;
182
+ expect ( select ) . toHaveClass ( 'testtest' ) ;
183
+ } ) ;
184
+
185
+ it ( 'should have index available' , function ( ) {
186
+ select . selectric ( {
187
+ optionsItemBuilder : function ( itemData , element , index ) {
188
+ return '<span class="item-' + index + '">' + itemData . text + '</span>' ;
189
+ }
190
+ } ) ;
191
+ expect ( $ ( '.selectric-items' ) . find ( 'li:first' ) . find ( '.item-0' ) . length ) . toBe ( 1 ) ;
168
192
} ) ;
169
- $ ( '.selectric' ) . click ( ) ;
170
- expect ( $ ( '.selectric-items' ) . find ( 'li.selected' ) . find ( 'span' ) . length ) . toBe ( 1 ) ;
171
193
} ) ;
172
194
173
195
it ( 'should have same width of original <select>' , function ( ) {
0 commit comments