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

Commit aec79c8

Browse files
author
Austin McDaniel
committed
Adding test for highlight
1 parent 3a3ad19 commit aec79c8

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

test/select.spec.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ describe('ui-select tests', function() {
253253
expect(isDropdownOpened(el2)).toEqual(true);
254254

255255
var el3 = createUiSelect();
256-
expect(el3.scope().$select.disabled).toEqual(false);
256+
expect(el3.scope().$select.disabled).toBeFalsy();
257257
clickMatch(el3);
258258
expect(isDropdownOpened(el3)).toEqual(true);
259259
});
@@ -724,6 +724,35 @@ describe('ui-select tests', function() {
724724

725725
});
726726

727+
it('should invoke hover callback', function(){
728+
729+
var highlighted;
730+
scope.onHighlightFn = function ($item) {
731+
highlighted = $item;
732+
};
733+
734+
var el = compileTemplate(
735+
'<ui-select on-select="onSelectFn($item, $model)" ng-model="selection.selected"> \
736+
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
737+
<ui-select-choices on-highlight="onHighlightFn(person)" repeat="person.name as person in people | filter: $select.search"> \
738+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
739+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
740+
</ui-select-choices> \
741+
</ui-select>'
742+
);
743+
744+
expect(highlighted).toBeFalsy();
745+
746+
if (!isDropdownOpened(el)){
747+
openDropdown(el);
748+
}
749+
750+
$(el).find('.ui-select-choices-row div:contains("Samantha")').trigger('mouseover');
751+
scope.$digest();
752+
753+
expect(highlighted).toBe(scope.people[5]);
754+
})
755+
727756
it('should set $item & $model correctly when invoking callback on select and no single prop. binding', function () {
728757

729758
scope.onSelectFn = function ($item, $model, $label) {

0 commit comments

Comments
 (0)