This repository has been archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat(typeahead): Adds 'select on exact' setting. #3365
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -456,6 +456,63 @@ describe('typeahead tests', function () { | |
expect(inputEl.val()).toEqual('AL'); | ||
}); | ||
}); | ||
|
||
describe('select on exact match', function(){ | ||
|
||
it('should select on an exact match when set', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these should be grouped under a describe block with the select on an exact match descriptor string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes I see I missed that. Done. |
||
|
||
$scope.onSelect = jasmine.createSpy('onSelect'); | ||
var element = prepareInputEl('<div><input ng-model="result" typeahead-editable="false" typeahead-on-select="onSelect()" typeahead="item for item in source | filter:$viewValue" typeahead-select-on-exact="true"></div>'); | ||
var inputEl = findInput(element); | ||
|
||
changeInputValueTo(element, 'bar'); | ||
|
||
expect($scope.result).toEqual('bar'); | ||
expect(inputEl.val()).toEqual('bar'); | ||
expect(element).toBeClosed(); | ||
expect($scope.onSelect).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not select on an exact match by default', function () { | ||
|
||
$scope.onSelect = jasmine.createSpy('onSelect'); | ||
var element = prepareInputEl('<div><input ng-model="result" typeahead-editable="false" typeahead-on-select="onSelect()" typeahead="item for item in source | filter:$viewValue"></div>'); | ||
var inputEl = findInput(element); | ||
|
||
changeInputValueTo(element, 'bar'); | ||
|
||
expect($scope.result).toBeUndefined(); | ||
expect(inputEl.val()).toEqual('bar'); | ||
expect($scope.onSelect.calls.any()).toBe(false); | ||
}); | ||
|
||
it('should not be case sensitive when select on an exact match', function () { | ||
|
||
$scope.onSelect = jasmine.createSpy('onSelect'); | ||
var element = prepareInputEl('<div><input ng-model="result" typeahead-editable="false" typeahead-on-select="onSelect()" typeahead="item for item in source | filter:$viewValue" typeahead-select-on-exact="true"></div>'); | ||
var inputEl = findInput(element); | ||
|
||
changeInputValueTo(element, 'BaR'); | ||
|
||
expect($scope.result).toEqual('bar'); | ||
expect(inputEl.val()).toEqual('bar'); | ||
expect(element).toBeClosed(); | ||
expect($scope.onSelect).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should not auto select when not a match with one potential result left', function () { | ||
|
||
$scope.onSelect = jasmine.createSpy('onSelect'); | ||
var element = prepareInputEl('<div><input ng-model="result" typeahead-editable="false" typeahead-on-select="onSelect()" typeahead="item for item in source | filter:$viewValue" typeahead-select-on-exact="true"></div>'); | ||
var inputEl = findInput(element); | ||
|
||
changeInputValueTo(element, 'fo'); | ||
|
||
expect($scope.result).toBeUndefined(); | ||
expect(inputEl.val()).toEqual('fo'); | ||
expect($scope.onSelect.calls.any()).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('pop-up interaction', function () { | ||
var element; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason this was moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I was looking for where to add the documentation for the new attribute, I noticed that they were almost in alphabetical order (except for focus-first) and assumed that they were supposed to be so I moved 'focus-first' to higher up in the list. Looking again, I see I misplaced 'select-on-exact' anyway... so I've fixed that now. I'm happy to order them differently if I'm incorrect.