Skip to content

Commit 030fe06

Browse files
committed
[Fix] Fixed parameter order in string score method and increased default minimum similarity score
1 parent e1dd659 commit 030fe06

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

AutoComplete/AutoComplete.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AutoComplete extends Component {
2626

2727
isSimilar = (value, suggestionText) => {
2828
const suggestionScore = stringScore(
29-
value, suggestionText, this.props.comparationFuzziness
29+
suggestionText, value, this.props.comparationFuzziness
3030
)
3131

3232
return suggestionScore >= this.props.minimumSimilarityScore
@@ -132,7 +132,7 @@ AutoComplete.propTypes = {
132132
}
133133

134134
AutoComplete.defaultProps = {
135-
minimumSimilarityScore: 0.45,
135+
minimumSimilarityScore: 0.6,
136136
comparationFuzziness: 0.5
137137
}
138138

AutoComplete/AutoComplete.spec.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ describe('AutoComplete', () => {
2727
const params = {
2828
value: '0.5',
2929
suggestions: fakeSuggestions,
30-
suggestionObjectTextProperty: 'text'
30+
suggestionObjectTextProperty: 'text',
31+
minimumSimilarityScore: 0.5
3132
}
3233

3334
const wrapper = shallow(
@@ -47,7 +48,8 @@ describe('AutoComplete', () => {
4748
let params = {
4849
value: '0.5',
4950
suggestions: fakeSuggestions,
50-
suggestionObjectTextProperty: 'text'
51+
suggestionObjectTextProperty: 'text',
52+
minimumSimilarityScore: 0.5
5153
}
5254

5355
const wrapper = shallow(
@@ -71,7 +73,8 @@ describe('AutoComplete', () => {
7173
value: '0.5',
7274
suggestions: fakeSuggestions,
7375
suggestionObjectTextProperty: 'text',
74-
onSelect: jest.fn()
76+
onSelect: jest.fn(),
77+
minimumSimilarityScore: 0.5
7578
}
7679

7780
const wrapper = shallow(

AutoComplete/__snapshots__/AutoComplete.spec.js.snap

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ShallowWrapper {
1414
}>
1515
<TextInput
1616
comparationFuzziness={0.5}
17-
minimumSimilarityScore={0.45}
17+
minimumSimilarityScore={0.6}
1818
onChangeText={[Function]}
1919
style={
2020
Object {
@@ -31,7 +31,7 @@ ShallowWrapper {
3131
}>
3232
<TextInput
3333
comparationFuzziness={0.5}
34-
minimumSimilarityScore={0.45}
34+
minimumSimilarityScore={0.6}
3535
onChangeText={[Function]}
3636
style={
3737
Object {
@@ -48,7 +48,7 @@ ShallowWrapper {
4848
"_context": Object {},
4949
"_currentElement": <AutoComplete
5050
comparationFuzziness={0.5}
51-
minimumSimilarityScore={0.45} />,
51+
minimumSimilarityScore={0.6} />,
5252
"_hostContainerInfo": null,
5353
"_hostParent": null,
5454
"_instance": AutoComplete {
@@ -60,7 +60,7 @@ ShallowWrapper {
6060
"onChangeText": [Function],
6161
"props": Object {
6262
"comparationFuzziness": 0.5,
63-
"minimumSimilarityScore": 0.45,
63+
"minimumSimilarityScore": 0.6,
6464
},
6565
"refs": Object {},
6666
"renderSuggestions": [Function],
@@ -93,7 +93,7 @@ ShallowWrapper {
9393
}>
9494
<TextInput
9595
comparationFuzziness={0.5}
96-
minimumSimilarityScore={0.45}
96+
minimumSimilarityScore={0.6}
9797
onChangeText={[Function]}
9898
style={
9999
Object {
@@ -109,7 +109,7 @@ ShallowWrapper {
109109
}>
110110
<TextInput
111111
comparationFuzziness={0.5}
112-
minimumSimilarityScore={0.45}
112+
minimumSimilarityScore={0.6}
113113
onChangeText={[Function]}
114114
style={
115115
Object {
@@ -129,6 +129,6 @@ ShallowWrapper {
129129
"root": [Circular],
130130
"unrendered": <AutoComplete
131131
comparationFuzziness={0.5}
132-
minimumSimilarityScore={0.45} />,
132+
minimumSimilarityScore={0.6} />,
133133
}
134134
`;

__mocks__/string_score.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const stringScore = (leftString, rightString) => {
2-
if (parseFloat(leftString) <= parseFloat(rightString)) {
2+
if (parseFloat(leftString) >= parseFloat(rightString)) {
33
return parseFloat(rightString)
44
}
55

0 commit comments

Comments
 (0)