@@ -80,6 +80,52 @@ 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
+
91
+ it ( 'should search alternative text' , function ( ) {
92
+ select . find ( 'option:eq(6)' ) . attr ( 'data-alt' , 'alt blackberry' ) ;
93
+ select . selectric ( 'refresh' ) ;
94
+ $ ( '.selectric-input' ) . val ( 'alt blackberry' ) . trigger ( 'input' ) ;
95
+ $ ( '.selectric-items' ) . find ( '.highlighted' ) . click ( ) ;
96
+ expect ( select . val ( ) ) . toBe ( 'blackberry' ) ;
97
+ } ) ;
98
+
99
+ it ( 'should search alternative text with separator' , function ( ) {
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' ) ;
103
+ $ ( '.selectric-items' ) . find ( '.highlighted' ) . click ( ) ;
104
+ expect ( select . val ( ) ) . toBe ( 'blackberry' ) ;
105
+ } ) ;
106
+
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' ) ;
110
+ $ ( '.selectric-input' ) . val ( 'another berry' ) . trigger ( 'input' ) ;
111
+ $ ( '.selectric-items' ) . find ( '.highlighted' ) . click ( ) ;
112
+ expect ( select . val ( ) ) . toBe ( 'blackberry' ) ;
113
+ } ) ;
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
+
122
+ it ( 'should skip blank alternative text with separator' , function ( ) {
123
+ select . find ( 'option:eq(6)' ) . attr ( 'data-alt' , '|' ) ;
124
+ select . selectric ( 'refresh' ) ;
125
+ $ ( '.selectric-input' ) . val ( 'a text that does not exist' ) . trigger ( 'input' ) ;
126
+ expect ( $ ( '.selectric-items' ) . find ( '.highlighted' ) . length ) . toBe ( 0 ) ;
127
+ } ) ;
128
+
83
129
it ( 'highlight() should return undefined if index is undefined' , function ( ) {
84
130
expect ( select . data ( 'selectric' ) . highlight ( undefined ) ) . toBe ( undefined ) ;
85
131
} ) ;
0 commit comments