-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for the HTML entity bug
This is the minimal reproducible test-case for this bug. There's one test for each flavor of chosen, and I've confirmed that this does, indeed, fail on master.
- Loading branch information
Arun Srinivasan
committed
Aug 22, 2017
1 parent
5940e3b
commit d4715b1
Showing
2 changed files
with
58 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
describe "Searching", -> | ||
it "should not match the actual text of HTML entities", -> | ||
tmpl = " | ||
<select data-placeholder='Choose an HTML Entity...'> | ||
<option value=''></option> | ||
<option value='This & That'>This & That</option> | ||
<option value='This < That'>This < That</option> | ||
</select> | ||
" | ||
|
||
div = $("<div>").html(tmpl) | ||
select = div.find("select") | ||
select.chosen({search_contains: true}) | ||
|
||
container = div.find(".chosen-container") | ||
container.trigger("mousedown") # open the drop | ||
|
||
# Both options should be active | ||
results = div.find(".active-result") | ||
expect(results.size()).toBe(2) | ||
|
||
# Search for the html entity by name | ||
search_field = div.find(".chosen-search input").first() | ||
search_field.val("mp") | ||
search_field.trigger("keyup") | ||
|
||
results = div.find(".active-result") | ||
expect(results.size()).toBe(0) |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe "Searching", -> | ||
it "should not match the actual text of HTML entities", -> | ||
tmpl = " | ||
<select data-placeholder='Choose an HTML Entity...'> | ||
<option value=''></option> | ||
<option value='This & That'>This & That</option> | ||
<option value='This < That'>This < That</option> | ||
</select> | ||
" | ||
|
||
div = new Element('div') | ||
document.body.insert(div) | ||
div.update(tmpl) | ||
select = div.down('select') | ||
new Chosen(select, {search_contains: true}) | ||
|
||
container = div.down('.chosen-container') | ||
simulant.fire(container, 'mousedown') # open the drop | ||
|
||
# Both options should be active | ||
results = div.select('.active-result') | ||
expect(results.length).toBe(2) | ||
|
||
# Search for the html entity by name | ||
search_field = div.down(".chosen-search input") | ||
search_field.value = "mp" | ||
simulant.fire(search_field, 'keyup') | ||
|
||
results = div.select(".active-result") | ||
expect(results.length).toBe(0) |