@@ -115,7 +115,7 @@ describe('getAutocompleteSuggestion', () => {
115
115
} ) ;
116
116
117
117
test ( 'result should be in priority of startsWith, contains in name, matches in email' , ( ) => {
118
- const user1 = eg . makeUser ( { name :
'M Apple' , email :
'[email protected] ' } ) ; // satisfy initials condition
118
+ const user1 = eg . makeUser ( { name :
'M Apple' , email :
'[email protected] ' } ) ; // does not match
119
119
const user2 = eg . makeUser ( { name :
'Normal boy' , email :
'[email protected] ' } ) ; // satisfy full_name contains condition
120
120
const user3 = eg . makeUser ( { name :
'example' , email :
'[email protected] ' } ) ; // random entry
121
121
const user4 = eg . makeUser ( { name :
'Example' , email :
'[email protected] ' } ) ; // satisfy email match condition
@@ -124,7 +124,7 @@ describe('getAutocompleteSuggestion', () => {
124
124
const user7 = eg . makeUser ( { name :
'Match App Normal' , email :
'[email protected] ' } ) ; // satisfy all conditions
125
125
const user8 = eg . makeUser ( { name :
'match' , email :
'[email protected] ' } ) ; // duplicate
126
126
const user9 = eg . makeUser ( { name :
'Laptop' , email :
'[email protected] ' } ) ; // random entry
127
- const user10 = eg . makeUser ( { name :
'Mobile App' , email :
'[email protected] ' } ) ; // satisfy initials and email condition
127
+ const user10 = eg . makeUser ( { name :
'Mobile App' , email :
'[email protected] ' } ) ; // satisfy email condition
128
128
const user11 = eg . makeUser ( { name :
'Normal' , email :
'[email protected] ' } ) ; // satisfy contains in name and matches in email condition
129
129
const allUsers = deepFreeze ( [
130
130
user1 ,
@@ -147,7 +147,7 @@ describe('getAutocompleteSuggestion', () => {
147
147
user2 , // name contains in 'ma'
148
148
user11 , // have priority because of 'ma' contains in name
149
149
user4 , // email contains 'ma'
150
- user10 , // have priority because of initials condition
150
+ user10 , // email contains 'ma'
151
151
] ;
152
152
const filteredUsers = getAutocompleteSuggestion (
153
153
allUsers ,
@@ -257,6 +257,24 @@ describe('filterUserStartWith', () => {
257
257
const expectedUsers = [ user1 , user3 ] ;
258
258
expect ( filterUserStartWith ( users , 'app' , selfUser . user_id ) ) . toEqual ( expectedUsers ) ;
259
259
} ) ;
260
+
261
+ test ( 'returns users whose name contains diacritics but otherwise starts with filter' , ( ) => {
262
+ const withDiacritics = eg . makeUser ( { name :
'Frödö' , email :
'[email protected] ' } ) ;
263
+ const withoutDiacritics = eg . makeUser ( { name :
'Frodo' , email :
'[email protected] ' } ) ;
264
+ const nonMatchingUser = eg . makeUser ( { name :
'Zalix' , email :
'[email protected] ' } ) ;
265
+ const users = deepFreeze ( [ withDiacritics , withoutDiacritics , nonMatchingUser ] ) ;
266
+ const expectedUsers = [ withDiacritics , withoutDiacritics ] ;
267
+ expect ( filterUserStartWith ( users , 'Fro' , eg . makeUser ( ) . user_id ) ) . toEqual ( expectedUsers ) ;
268
+ } ) ;
269
+
270
+ test ( 'returns users whose name contains diacritics and filter uses diacritics' , ( ) => {
271
+ const withDiacritics = eg . makeUser ( { name :
'Frödö' , email :
'[email protected] ' } ) ;
272
+ const withoutDiacritics = eg . makeUser ( { name :
'Frodo' , email :
'[email protected] ' } ) ;
273
+ const nonMatchingUser = eg . makeUser ( { name :
'Zalix' , email :
'[email protected] ' } ) ;
274
+ const users = deepFreeze ( [ withDiacritics , withoutDiacritics , nonMatchingUser ] ) ;
275
+ const expectedUsers = [ withDiacritics ] ;
276
+ expect ( filterUserStartWith ( users , 'Frö' , eg . makeUser ( ) . user_id ) ) . toEqual ( expectedUsers ) ;
277
+ } ) ;
260
278
} ) ;
261
279
262
280
describe ( 'groupUsersByStatus' , ( ) => {
@@ -312,6 +330,24 @@ describe('filterUserThatContains', () => {
312
330
const expectedUsers = [ user2 , user5 ] ;
313
331
expect ( filterUserThatContains ( users , 'ma' , selfUser . user_id ) ) . toEqual ( expectedUsers ) ;
314
332
} ) ;
333
+
334
+ test ( 'returns users whose full_name has diacritics but otherwise contains filter' , ( ) => {
335
+ const withDiacritics = eg . makeUser ( { name :
'Aärdvärk' , email :
'[email protected] ' } ) ;
336
+ const withoutDiacritics = eg . makeUser ( { name :
'Aardvark' , email :
'[email protected] ' } ) ;
337
+ const nonMatchingUser = eg . makeUser ( { name :
'Turtle' , email :
'[email protected] ' } ) ;
338
+ const users = deepFreeze ( [ withDiacritics , withoutDiacritics , nonMatchingUser ] ) ;
339
+ const expectedUsers = [ withDiacritics , withoutDiacritics ] ;
340
+ expect ( filterUserThatContains ( users , 'vark' , eg . makeUser ( ) . user_id ) ) . toEqual ( expectedUsers ) ;
341
+ } ) ;
342
+
343
+ test ( 'returns users whose full_name has diacritics and filter uses diacritics' , ( ) => {
344
+ const withDiacritics = eg . makeUser ( { name :
'Aärdvärk' , email :
'[email protected] ' } ) ;
345
+ const withoutDiacritics = eg . makeUser ( { name :
'Aardvark' , email :
'[email protected] ' } ) ;
346
+ const nonMatchingUser = eg . makeUser ( { name :
'Turtle' , email :
'[email protected] ' } ) ;
347
+ const users = deepFreeze ( [ withDiacritics , withoutDiacritics , nonMatchingUser ] ) ;
348
+ const expectedUsers = [ withDiacritics ] ;
349
+ expect ( filterUserThatContains ( users , 'värk' , eg . makeUser ( ) . user_id ) ) . toEqual ( expectedUsers ) ;
350
+ } ) ;
315
351
} ) ;
316
352
317
353
describe ( 'filterUserMatchesEmail' , ( ) => {
0 commit comments