@@ -13,40 +13,26 @@ function attr(type?: InstanceAttribute['type']): InstanceAttribute {
1313}
1414
1515describe ( 'translateStringSearchType' , ( ) => {
16- it ( 'returns equals when both anchors are present' , ( ) => {
17- expect ( translateStringSearchType ( true , true , attr ( 'String' ) ) ) . toBe ( 'equals' ) ;
18- } ) ;
19-
2016 it ( 'returns starts_with when only start anchor is present' , ( ) => {
21- expect ( translateStringSearchType ( true , false , attr ( 'String' ) ) ) . toBe ( 'starts_with' ) ;
22- } ) ;
23-
24- it ( 'returns ends_with when only end anchor is present' , ( ) => {
25- expect ( translateStringSearchType ( false , true , attr ( 'String' ) ) ) . toBe ( 'ends_with' ) ;
17+ expect ( translateStringSearchType ( true , attr ( 'String' ) ) ) . toBe ( 'starts_with' ) ;
2618 } ) ;
2719
2820 it ( 'returns equals for ID type when no anchors' , ( ) => {
29- expect ( translateStringSearchType ( false , false , attr ( 'ID' ) ) ) . toBe ( 'equals' ) ;
21+ expect ( translateStringSearchType ( false , attr ( 'ID' ) ) ) . toBe ( 'equals' ) ;
3022 } ) ;
3123
32- it ( 'defaults to starts_with when no anchors and non-ID' , ( ) => {
33- expect ( translateStringSearchType ( false , false , attr ( 'String' ) ) ) . toBe ( 'starts_with ' ) ;
34- expect ( translateStringSearchType ( false , false , attr ( 'Date' ) ) ) . toBe ( 'starts_with ' ) ;
24+ it ( 'defaults to equals when no anchors and non-ID' , ( ) => {
25+ expect ( translateStringSearchType ( false , attr ( 'String' ) ) ) . toBe ( 'equals ' ) ;
26+ expect ( translateStringSearchType ( false , attr ( 'Date' ) ) ) . toBe ( 'equals ' ) ;
3527 } ) ;
3628} ) ;
3729
3830describe ( 'translateStringSearchValue' , ( ) => {
39- it ( 'strips both anchors' , ( ) => {
40- expect ( translateStringSearchValue ( true , true , '^foo$' ) ) . toBe ( 'foo' ) ;
41- } ) ;
42- it ( 'strips start anchor only' , ( ) => {
43- expect ( translateStringSearchValue ( true , false , '^foo' ) ) . toBe ( 'foo' ) ;
44- } ) ;
45- it ( 'strips end anchor only' , ( ) => {
46- expect ( translateStringSearchValue ( false , true , 'foo$' ) ) . toBe ( 'foo' ) ;
31+ it ( 'strips start anchor' , ( ) => {
32+ expect ( translateStringSearchValue ( true , 'foo*' ) ) . toBe ( 'foo' ) ;
4733 } ) ;
4834 it ( 'returns as-is with no anchors' , ( ) => {
49- expect ( translateStringSearchValue ( false , false , 'foo' ) ) . toBe ( 'foo' ) ;
35+ expect ( translateStringSearchValue ( false , 'foo' ) ) . toBe ( 'foo' ) ;
5036 } ) ;
5137} ) ;
5238
@@ -87,26 +73,26 @@ describe('translateBooleanValue', () => {
8773describe ( 'translateColumnFilterToSearchCondition' , ( ) => {
8874 it ( 'handles String attribute with anchors' , ( ) => {
8975 expect (
90- translateColumnFilterToSearchCondition ( 'name' , '^ foo$ ' , attr ( 'String' ) ) ,
76+ translateColumnFilterToSearchCondition ( 'name' , 'foo' , attr ( 'String' ) ) ,
9177 ) . toEqual ( {
9278 search_attribute : 'name' ,
9379 search_type : 'equals' ,
9480 search_value : 'foo' ,
9581 } ) ;
9682
9783 expect (
98- translateColumnFilterToSearchCondition ( 'name' , 'bar$ ' , attr ( 'String' ) ) ,
84+ translateColumnFilterToSearchCondition ( 'name' , 'bar* ' , attr ( 'String' ) ) ,
9985 ) . toEqual ( {
10086 search_attribute : 'name' ,
101- search_type : 'ends_with ' ,
87+ search_type : 'starts_with ' ,
10288 search_value : 'bar' ,
10389 } ) ;
10490
10591 expect (
10692 translateColumnFilterToSearchCondition ( 'name' , 'baz' , attr ( 'String' ) ) ,
10793 ) . toEqual ( {
10894 search_attribute : 'name' ,
109- search_type : 'starts_with ' ,
95+ search_type : 'equals ' ,
11096 search_value : 'baz' ,
11197 } ) ;
11298 } ) ;
0 commit comments