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

Commit 82d6aec

Browse files
SimeonSimeon
Simeon
authored and
Simeon
committed
Added parser tests in addition to the previous formatter tests.
1 parent 13808f1 commit 82d6aec

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

test/select.spec.js

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ describe('ui-select tests', function() {
295295
}).toThrow(new Error('[ui.select:transcluded] Expected 1 .ui-select-match but got \'0\'.'));
296296
});
297297

298-
it('should parse and format the model correctly using alias', function() {
298+
it('should format the model correctly using alias', function() {
299299
var el = compileTemplate(
300300
'<ui-select ng-model="selection.selected"> \
301301
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
@@ -309,7 +309,22 @@ describe('ui-select tests', function() {
309309
expect(scope.selection.selected).toBe(scope.people[5]);
310310
});
311311

312-
it('should parse and format the model correctly using property of alias', function() {
312+
it('should parse the model correctly using alias', function() {
313+
var el = compileTemplate(
314+
'<ui-select ng-model="selection.selected"> \
315+
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
316+
<ui-select-choices repeat="person as person in people | filter: $select.search"> \
317+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
318+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
319+
</ui-select-choices> \
320+
</ui-select>'
321+
);
322+
scope.selection.selected = scope.people[5];
323+
scope.$digest();
324+
expect(getMatchLabel(el)).toEqual('Samantha');
325+
});
326+
327+
it('should format the model correctly using property of alias', function() {
313328
var el = compileTemplate(
314329
'<ui-select ng-model="selection.selected"> \
315330
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
@@ -323,9 +338,46 @@ describe('ui-select tests', function() {
323338
expect(scope.selection.selected).toBe('Samantha');
324339
});
325340

326-
it('should parse and format the model correctly without alias', function() {
341+
it('should parse the model correctly using property of alias', function() {
342+
var el = compileTemplate(
343+
'<ui-select ng-model="selection.selected"> \
344+
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
345+
<ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
346+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
347+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
348+
</ui-select-choices> \
349+
</ui-select>'
350+
);
351+
scope.selection.selected = 'Samantha';
352+
scope.$digest();
353+
expect(getMatchLabel(el)).toEqual('Samantha');
354+
});
355+
356+
it('should parse the model correctly using property of alias but passed whole object', function() {
357+
var el = compileTemplate(
358+
'<ui-select ng-model="selection.selected"> \
359+
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
360+
<ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
361+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
362+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
363+
</ui-select-choices> \
364+
</ui-select>'
365+
);
366+
scope.selection.selected = scope.people[5];
367+
scope.$digest();
368+
expect(getMatchLabel(el)).toEqual('Samantha');
369+
});
370+
371+
it('should format the model correctly without alias', function() {
327372
var el = createUiSelect();
328373
clickItem(el, 'Samantha');
329374
expect(scope.selection.selected).toBe(scope.people[5]);
330375
});
376+
377+
it('should parse the model correctly without alias', function() {
378+
var el = createUiSelect();
379+
scope.selection.selected = scope.people[5];
380+
scope.$digest();
381+
expect(getMatchLabel(el)).toEqual('Samantha');
382+
});
331383
});

0 commit comments

Comments
 (0)