11// cspell:ignore René Résumé
22import deburr from 'lodash/deburr' ;
3- import { isPersonalDetailMatchingSearchTerm } from '@libs/OptionsListUtils/searchMatchUtils' ;
3+ import { doesPersonalDetailMatchSearchTerm } from '@libs/OptionsListUtils/searchMatchUtils' ;
44
55const CURRENT_USER_ACCOUNT_ID = 2 ;
66const OTHER_USER_ACCOUNT_ID = 99 ;
77
8- describe ( 'isPersonalDetailMatchingSearchTerm ' , ( ) => {
8+ describe ( 'doesPersonalDetailMatchSearchTerm ' , ( ) => {
99 describe ( 'basic matching' , ( ) => {
1010 it ( 'should match by displayName' , ( ) => {
11- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'John Doe' } , OTHER_USER_ACCOUNT_ID , 'john' ) ) . toBe ( true ) ;
11+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'John Doe' } , OTHER_USER_ACCOUNT_ID , 'john' ) ) . toBe ( true ) ;
1212 } ) ;
1313
1414 it ( 'should match by login (email)' , ( ) => {
15- expect ( isPersonalDetailMatchingSearchTerm ( { login : 'john@example.com' } , OTHER_USER_ACCOUNT_ID , 'john@example' ) ) . toBe ( true ) ;
15+ expect ( doesPersonalDetailMatchSearchTerm ( { login : 'john@example.com' } , OTHER_USER_ACCOUNT_ID , 'john@example' ) ) . toBe ( true ) ;
1616 } ) ;
1717
1818 it ( 'should match by login without dots before @' , ( ) => {
19- expect ( isPersonalDetailMatchingSearchTerm ( { login : 'john.doe@example.com' } , OTHER_USER_ACCOUNT_ID , 'johndoe@' ) ) . toBe ( true ) ;
19+ expect ( doesPersonalDetailMatchSearchTerm ( { login : 'john.doe@example.com' } , OTHER_USER_ACCOUNT_ID , 'johndoe@' ) ) . toBe ( true ) ;
2020 } ) ;
2121
2222 it ( 'should match by participantsList displayName' , ( ) => {
2323 const item = { participantsList : [ { displayName : 'Jane Smith' , accountID : 123 } ] } ;
24- expect ( isPersonalDetailMatchingSearchTerm ( item , OTHER_USER_ACCOUNT_ID , 'jane' ) ) . toBe ( true ) ;
24+ expect ( doesPersonalDetailMatchSearchTerm ( item , OTHER_USER_ACCOUNT_ID , 'jane' ) ) . toBe ( true ) ;
2525 } ) ;
2626
2727 it ( 'should not match when search term is absent from all fields' , ( ) => {
28- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'Alice' , login : 'alice@test.com' } , OTHER_USER_ACCOUNT_ID , 'bob' ) ) . toBe ( false ) ;
28+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'Alice' , login : 'alice@test.com' } , OTHER_USER_ACCOUNT_ID , 'bob' ) ) . toBe ( false ) ;
2929 } ) ;
3030
3131 it ( 'should match when search term is empty string' , ( ) => {
32- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'Anyone' } , OTHER_USER_ACCOUNT_ID , '' ) ) . toBe ( true ) ;
32+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'Anyone' } , OTHER_USER_ACCOUNT_ID , '' ) ) . toBe ( true ) ;
3333 } ) ;
3434 } ) ;
3535
3636 describe ( 'case insensitivity' , ( ) => {
3737 it ( 'should match mixed case displayName against lowercased search' , ( ) => {
38- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'John DOE' } , OTHER_USER_ACCOUNT_ID , 'john doe' ) ) . toBe ( true ) ;
38+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'John DOE' } , OTHER_USER_ACCOUNT_ID , 'john doe' ) ) . toBe ( true ) ;
3939 } ) ;
4040
4141 it ( 'should match mixed case login against lowercased search' , ( ) => {
42- expect ( isPersonalDetailMatchingSearchTerm ( { login : 'John.Doe@Example.COM' } , OTHER_USER_ACCOUNT_ID , 'john.doe@example.com' ) ) . toBe ( true ) ;
42+ expect ( doesPersonalDetailMatchSearchTerm ( { login : 'John.Doe@Example.COM' } , OTHER_USER_ACCOUNT_ID , 'john.doe@example.com' ) ) . toBe ( true ) ;
4343 } ) ;
4444 } ) ;
4545
4646 describe ( 'current user matching' , ( ) => {
4747 it ( 'should match by text field for current user' , ( ) => {
48- expect ( isPersonalDetailMatchingSearchTerm ( { accountID : CURRENT_USER_ACCOUNT_ID , text : 'My Display Name' } , CURRENT_USER_ACCOUNT_ID , 'my display' ) ) . toBe ( true ) ;
48+ expect ( doesPersonalDetailMatchSearchTerm ( { accountID : CURRENT_USER_ACCOUNT_ID , text : 'My Display Name' } , CURRENT_USER_ACCOUNT_ID , 'my display' ) ) . toBe ( true ) ;
4949 } ) ;
5050
5151 it ( 'should fall back to displayName when text is missing for current user' , ( ) => {
52- expect ( isPersonalDetailMatchingSearchTerm ( { accountID : CURRENT_USER_ACCOUNT_ID , displayName : 'Fallback Name' } , CURRENT_USER_ACCOUNT_ID , 'fallback' ) ) . toBe ( true ) ;
52+ expect ( doesPersonalDetailMatchSearchTerm ( { accountID : CURRENT_USER_ACCOUNT_ID , displayName : 'Fallback Name' } , CURRENT_USER_ACCOUNT_ID , 'fallback' ) ) . toBe ( true ) ;
5353 } ) ;
5454 } ) ;
5555
5656 describe ( 'partial / sparse items' , ( ) => {
5757 it ( 'should match with only login provided' , ( ) => {
58- expect ( isPersonalDetailMatchingSearchTerm ( { login : 'solo@test.com' } , OTHER_USER_ACCOUNT_ID , 'solo' ) ) . toBe ( true ) ;
58+ expect ( doesPersonalDetailMatchSearchTerm ( { login : 'solo@test.com' } , OTHER_USER_ACCOUNT_ID , 'solo' ) ) . toBe ( true ) ;
5959 } ) ;
6060
6161 it ( 'should match with only displayName provided' , ( ) => {
62- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'Solo' } , OTHER_USER_ACCOUNT_ID , 'solo' ) ) . toBe ( true ) ;
62+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'Solo' } , OTHER_USER_ACCOUNT_ID , 'solo' ) ) . toBe ( true ) ;
6363 } ) ;
6464
6565 it ( 'should not match empty item with a search term' , ( ) => {
66- expect ( isPersonalDetailMatchingSearchTerm ( { } , OTHER_USER_ACCOUNT_ID , 'anything' ) ) . toBe ( false ) ;
66+ expect ( doesPersonalDetailMatchSearchTerm ( { } , OTHER_USER_ACCOUNT_ID , 'anything' ) ) . toBe ( false ) ;
6767 } ) ;
6868
6969 it ( 'should match empty item with empty search term' , ( ) => {
70- expect ( isPersonalDetailMatchingSearchTerm ( { } , OTHER_USER_ACCOUNT_ID , '' ) ) . toBe ( true ) ;
70+ expect ( doesPersonalDetailMatchSearchTerm ( { } , OTHER_USER_ACCOUNT_ID , '' ) ) . toBe ( true ) ;
7171 } ) ;
7272 } ) ;
7373
7474 describe ( 'cross-field matching' , ( ) => {
7575 it ( 'should match a search term that spans displayName and login' , ( ) => {
76- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'John' , login : 'doe@test.com' } , OTHER_USER_ACCOUNT_ID , 'john doe' ) ) . toBe ( true ) ;
76+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'John' , login : 'doe@test.com' } , OTHER_USER_ACCOUNT_ID , 'john doe' ) ) . toBe ( true ) ;
7777 } ) ;
7878 } ) ;
7979
8080 describe ( 'useLocaleLowerCase config' , ( ) => {
8181 it ( 'should lowercase with toLocaleLowerCase when enabled' , ( ) => {
8282 expect (
83- isPersonalDetailMatchingSearchTerm ( { displayName : 'ISTANBUL' } , OTHER_USER_ACCOUNT_ID , 'istanbul' , {
83+ doesPersonalDetailMatchSearchTerm ( { displayName : 'ISTANBUL' } , OTHER_USER_ACCOUNT_ID , 'istanbul' , {
8484 useLocaleLowerCase : true ,
8585 } ) ,
8686 ) . toBe ( true ) ;
8787 } ) ;
8888
8989 it ( 'should lowercase with toLowerCase by default' , ( ) => {
90- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'ISTANBUL' } , OTHER_USER_ACCOUNT_ID , 'istanbul' ) ) . toBe ( true ) ;
90+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'ISTANBUL' } , OTHER_USER_ACCOUNT_ID , 'istanbul' ) ) . toBe ( true ) ;
9191 } ) ;
9292 } ) ;
9393
9494 describe ( 'transformSearchText config' , ( ) => {
9595 it ( 'should match against appended text from transform callback' , ( ) => {
9696 expect (
97- isPersonalDetailMatchingSearchTerm ( { displayName : 'John' } , OTHER_USER_ACCOUNT_ID , 'extra' , {
97+ doesPersonalDetailMatchSearchTerm ( { displayName : 'John' } , OTHER_USER_ACCOUNT_ID , 'extra' , {
9898 transformSearchText : ( concatenatedSearchTerms ) => `${ concatenatedSearchTerms } extra stuff` ,
9999 } ) ,
100100 ) . toBe ( true ) ;
101101 } ) ;
102102
103103 it ( 'should pass already-lowercased terms to the transform callback' , ( ) => {
104104 let receivedText = '' ;
105- isPersonalDetailMatchingSearchTerm ( { displayName : 'UPPER Case' } , OTHER_USER_ACCOUNT_ID , 'test' , {
105+ doesPersonalDetailMatchSearchTerm ( { displayName : 'UPPER Case' } , OTHER_USER_ACCOUNT_ID , 'test' , {
106106 transformSearchText : ( concatenatedSearchTerms ) => {
107107 receivedText = concatenatedSearchTerms ;
108108 return concatenatedSearchTerms ;
@@ -113,15 +113,15 @@ describe('isPersonalDetailMatchingSearchTerm', () => {
113113
114114 it ( 'should use the transform result as the final match target' , ( ) => {
115115 expect (
116- isPersonalDetailMatchingSearchTerm ( { displayName : 'Alice' } , OTHER_USER_ACCOUNT_ID , 'replaced' , {
116+ doesPersonalDetailMatchSearchTerm ( { displayName : 'Alice' } , OTHER_USER_ACCOUNT_ID , 'replaced' , {
117117 transformSearchText : ( ) => 'completely replaced' ,
118118 } ) ,
119119 ) . toBe ( true ) ;
120120 } ) ;
121121
122122 it ( 'should support deburr with appended text (real-world usage)' , ( ) => {
123123 expect (
124- isPersonalDetailMatchingSearchTerm ( { displayName : 'René' } , OTHER_USER_ACCOUNT_ID , 'rene' , {
124+ doesPersonalDetailMatchSearchTerm ( { displayName : 'René' } , OTHER_USER_ACCOUNT_ID , 'rene' , {
125125 useLocaleLowerCase : true ,
126126 transformSearchText : ( concatenatedSearchTerms ) => deburr ( `${ concatenatedSearchTerms } ${ 'Résumé' . toLocaleLowerCase ( ) } ` ) ,
127127 } ) ,
@@ -131,15 +131,15 @@ describe('isPersonalDetailMatchingSearchTerm', () => {
131131
132132 describe ( 'negative cases' , ( ) => {
133133 it ( 'should not match when search term is longer than all fields' , ( ) => {
134- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'Jo' } , OTHER_USER_ACCOUNT_ID , 'john' ) ) . toBe ( false ) ;
134+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'Jo' } , OTHER_USER_ACCOUNT_ID , 'john' ) ) . toBe ( false ) ;
135135 } ) ;
136136
137137 it ( 'should not match when search contains characters not in any field' , ( ) => {
138- expect ( isPersonalDetailMatchingSearchTerm ( { displayName : 'John' } , OTHER_USER_ACCOUNT_ID , 'john!' ) ) . toBe ( false ) ;
138+ expect ( doesPersonalDetailMatchSearchTerm ( { displayName : 'John' } , OTHER_USER_ACCOUNT_ID , 'john!' ) ) . toBe ( false ) ;
139139 } ) ;
140140
141141 it ( 'should not crash with undefined accountID' , ( ) => {
142- expect ( isPersonalDetailMatchingSearchTerm ( { accountID : undefined , displayName : 'Test' } , CURRENT_USER_ACCOUNT_ID , 'test' ) ) . toBe ( true ) ;
142+ expect ( doesPersonalDetailMatchSearchTerm ( { accountID : undefined , displayName : 'Test' } , CURRENT_USER_ACCOUNT_ID , 'test' ) ) . toBe ( true ) ;
143143 } ) ;
144144 } ) ;
145145} ) ;
0 commit comments