Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit db9971e

Browse files
committed
Add test for null/undefined values
1 parent f87f84c commit db9971e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

test/select.spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,44 @@ describe('ui-select tests', function() {
21612161
expect(el.scope().$select.multiple).toBe(true);
21622162
});
21632163

2164+
it('should have tolerance for undefined values', function () {
2165+
2166+
scope.modelValue = undefined;
2167+
2168+
var el = compileTemplate(
2169+
'<ui-select multiple ng-model="modelValue" theme="bootstrap" style="width: 800px;"> \
2170+
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
2171+
<ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
2172+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
2173+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
2174+
</ui-select-choices> \
2175+
</ui-select> \
2176+
'
2177+
);
2178+
2179+
expect($(el).scope().$select.selected).toEqual([]);
2180+
2181+
});
2182+
2183+
it('should have tolerance for null values', function () {
2184+
2185+
scope.modelValue = null;
2186+
2187+
var el = compileTemplate(
2188+
'<ui-select multiple ng-model="modelValue" theme="bootstrap" style="width: 800px;"> \
2189+
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
2190+
<ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
2191+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
2192+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
2193+
</ui-select-choices> \
2194+
</ui-select> \
2195+
'
2196+
);
2197+
2198+
expect($(el).scope().$select.selected).toEqual([]);
2199+
2200+
});
2201+
21642202
it('should allow paste tag from clipboard', function() {
21652203
scope.taggingFunc = function (name) {
21662204
return {

0 commit comments

Comments
 (0)