File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ angular.module('ui.select', [])
55
55
* keyIdentifier = undefined
56
56
*/
57
57
self . parse = function ( expression ) {
58
+ if ( ! expression ) {
59
+ throw uiSelectMinErr ( 'repeat' , "Expected 'repeat' expression." ) ;
60
+ }
61
+
58
62
var match = expression . match ( / ^ \s * ( [ \s \S ] + ?) \s + i n \s + ( [ \s \S ] + ?) (?: \s + t r a c k \s + b y \s + ( [ \s \S ] + ?) ) ? \s * $ / ) ;
59
63
60
64
if ( ! match ) {
Original file line number Diff line number Diff line change @@ -182,4 +182,33 @@ describe('ui-select tests', function() {
182
182
expect ( el . scope ( ) . $select . selected ) . toEqual ( 'false' ) ;
183
183
expect ( getMatchLabel ( el ) ) . toEqual ( 'false' ) ;
184
184
} ) ;
185
- } ) ;
185
+
186
+ it ( 'should throw when no ui-select-choices found' , function ( ) {
187
+ expect ( function ( ) {
188
+ compileTemplate (
189
+ '<ui-select ng-model="selection"> \
190
+ <ui-select-match></ui-select-match> \
191
+ </ui-select>'
192
+ ) ;
193
+ } ) . toThrow ( new Error ( '[ui.select:transcluded] Expected 1 .ui-select-choices but got \'0\'.' ) ) ;
194
+ } ) ;
195
+
196
+ it ( 'should throw when no repeat attribute is provided to ui-select-choices' , function ( ) {
197
+ expect ( function ( ) {
198
+ compileTemplate (
199
+ '<ui-select ng-model="selection"> \
200
+ <ui-select-choices></ui-select-choices> \
201
+ </ui-select>'
202
+ ) ;
203
+ } ) . toThrow ( new Error ( '[ui.select:repeat] Expected \'repeat\' expression.' ) ) ;
204
+ } ) ;
205
+
206
+ it ( 'should throw when no ui-select-match found' , function ( ) {
207
+ expect ( function ( ) {
208
+ compileTemplate (
209
+ '<ui-select ng-model="selection"> \
210
+ <ui-select-choices repeat="item in items"></ui-select-choices> \
211
+ </ui-select>'
212
+ ) ;
213
+ } ) . toThrow ( new Error ( '[ui.select:transcluded] Expected 1 .ui-select-match but got \'0\'.' ) ) ;
214
+ } ) ; } ) ;
You can’t perform that action at this time.
0 commit comments