Skip to content

Commit 14bf1ff

Browse files
Michael Nomitchsimonista
authored andcommitted
due date picker matches anywhere in the string
fixes CNVS-21000 test plan: - go to new assignment page - search by a students last name - you are able to find the student this way Change-Id: I909b72aa74e4245a56bc3a9839a5ebb075116f2e Reviewed-on: https://gerrit.instructure.com/55912 Reviewed-by: Simon Williams <simon@instructure.com> Tested-by: Jenkins QA-Review: Adam Stone <astone@instructure.com> Product-Review: Jason Sparks <jsparks@instructure.com>
1 parent b694cf6 commit 14bf1ff

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

app/jsx/due_dates/DueDateTokenWrapper.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ define([
7777

7878
findMatchingOption(userInput){
7979
if(typeof userInput !== 'string') { return userInput }
80-
return this.enumerableStartsWith(userInput, _.find)
80+
return this.enumerableContainsString(userInput, _.find)
8181
},
8282

8383
suppressKeys(e){
@@ -102,9 +102,9 @@ define([
102102
})
103103
},
104104

105-
enumerableStartsWith(userInput, enumerable){
105+
enumerableContainsString(userInput, enumerable){
106106
var escapedInput = rEscape(userInput)
107-
var filter = new RegExp('^' + escapedInput, 'i')
107+
var filter = new RegExp(escapedInput, 'i')
108108
return enumerable(this.props.potentialOptions, function(option){
109109
return filter.test(option.name)
110110
})
@@ -116,7 +116,7 @@ define([
116116

117117
filteredTags() {
118118
if (this.state.userInput === '') return this.props.potentialOptions
119-
return this.enumerableStartsWith(this.state.userInput, _.filter)
119+
return this.enumerableContainsString(this.state.userInput, _.filter)
120120
},
121121

122122
// -------------------

spec/coffeescripts/jsx/due_dates/DueDateTokenWrapperSpec.coffee

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ define [
2121
]
2222
potentialOptions: [
2323
{course_section_id: "1", name: "Patricians"},
24-
{id: "1", name: "Seneca"},
24+
{id: "1", name: "Seneca The Elder"},
2525
{id: "2", name: "Agrippa"},
2626
{id: "3", name: "Publius"},
2727
{id: "4", name: "Scipio"},
@@ -69,7 +69,7 @@ define [
6969
equal @DueDateTokenWrapper.optionsForMenu()[1].props.value, "course_section"
7070
equal @DueDateTokenWrapper.optionsForMenu()[2].props.value, "Patricians"
7171
equal @DueDateTokenWrapper.optionsForMenu()[4].props.value, "student"
72-
equal @DueDateTokenWrapper.optionsForMenu()[5].props.value, "Seneca"
72+
equal @DueDateTokenWrapper.optionsForMenu()[5].props.value, "Seneca The Elder"
7373

7474
test 'handleTokenAdd is called when a token is added', ->
7575
addProp = @sandbox.stub(@DueDateTokenWrapper.props, "handleTokenAdd")
@@ -90,3 +90,7 @@ define [
9090
test 'findMatchingOption can handle strings with weird characters', ->
9191
foundToken = @DueDateTokenWrapper.findMatchingOption("Plebs | [")
9292
equal foundToken["name"], "Plebs | [ $"
93+
94+
test 'findMatchingOption can match characters in the middle of a string', ->
95+
foundToken = @DueDateTokenWrapper.findMatchingOption("The Elder")
96+
equal foundToken["name"], "Seneca The Elder"

0 commit comments

Comments
 (0)