@@ -80,24 +80,45 @@ describe('basic suite', function() {
80
80
expect ( select . val ( ) ) . toBe ( 'banana' ) ;
81
81
} ) ;
82
82
83
+ it ( 'should not search a disabled option' , function ( ) {
84
+ select . find ( 'option:eq(4)' ) . prop ( 'disabled' , 'disabled' ) ;
85
+ select . selectric ( 'refresh' ) ;
86
+ $ ( '.selectric-input' ) . val ( 'banana' ) . trigger ( 'input' ) ;
87
+ $ ( '.selectric-items' ) . find ( '.highlighted' ) . lenght ;
88
+ expect ( $ ( '.selectric-items' ) . find ( '.highlighted' ) . length ) . toBe ( 0 ) ;
89
+ } ) ;
90
+
83
91
it ( 'should search alternative text' , function ( ) {
84
- $ ( '.selectric-input' ) . val ( 'alt banana' ) . trigger ( 'input' ) ;
92
+ select . find ( 'option:eq(6)' ) . attr ( 'data-alt' , 'alt blackberry' ) ;
93
+ select . selectric ( 'refresh' ) ;
94
+ $ ( '.selectric-input' ) . val ( 'alt blackberry' ) . trigger ( 'input' ) ;
85
95
$ ( '.selectric-items' ) . find ( '.highlighted' ) . click ( ) ;
86
- expect ( select . val ( ) ) . toBe ( 'banana ' ) ;
96
+ expect ( select . val ( ) ) . toBe ( 'blackberry ' ) ;
87
97
} ) ;
88
98
89
99
it ( 'should search alternative text with separator' , function ( ) {
90
- $ ( '.selectric-input' ) . val ( 'altberry' ) . trigger ( 'input' ) ;
100
+ select . find ( 'option:eq(6)' ) . attr ( 'data-alt' , 'alt blackberry | another berry' ) ;
101
+ select . selectric ( 'refresh' ) ;
102
+ $ ( '.selectric-input' ) . val ( 'alt blackberry' ) . trigger ( 'input' ) ;
91
103
$ ( '.selectric-items' ) . find ( '.highlighted' ) . click ( ) ;
92
- expect ( select . val ( ) ) . toBe ( 'bilberry ' ) ;
104
+ expect ( select . val ( ) ) . toBe ( 'blackberry ' ) ;
93
105
} ) ;
94
106
95
107
it ( 'should search alternative text with separator 2' , function ( ) {
108
+ select . find ( 'option:eq(6)' ) . attr ( 'data-alt' , 'alt blackberry | another berry' ) ;
109
+ select . selectric ( 'refresh' ) ;
96
110
$ ( '.selectric-input' ) . val ( 'another berry' ) . trigger ( 'input' ) ;
97
111
$ ( '.selectric-items' ) . find ( '.highlighted' ) . click ( ) ;
98
- expect ( select . val ( ) ) . toBe ( 'bilberry ' ) ;
112
+ expect ( select . val ( ) ) . toBe ( 'blackberry ' ) ;
99
113
} ) ;
100
114
115
+ it ( 'should skip blank alternative text' , function ( ) {
116
+ select . find ( 'option:eq(6)' ) . attr ( 'data-alt' , '' ) ;
117
+ select . selectric ( 'refresh' ) ;
118
+ $ ( '.selectric-input' ) . val ( 'a text that does not exist' ) . trigger ( 'input' ) ;
119
+ expect ( $ ( '.selectric-items' ) . find ( '.highlighted' ) . length ) . toBe ( 0 ) ;
120
+ } ) ;
121
+
101
122
it ( 'highlight() should return undefined if index is undefined' , function ( ) {
102
123
expect ( select . data ( 'selectric' ) . highlight ( undefined ) ) . toBe ( undefined ) ;
103
124
} ) ;
0 commit comments