File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,12 @@ export interface Comparable {
9
9
}
10
10
11
11
export function isComparable ( arg : any ) : arg is Comparable {
12
- return arg && isFunction ( arg . equals )
12
+ return (
13
+ arg &&
14
+ isFunction ( arg . equals ) &&
15
+ isFunction ( arg . gt ) &&
16
+ isFunction ( arg . geq ) &&
17
+ isFunction ( arg . lt ) &&
18
+ isFunction ( arg . leq )
19
+ )
13
20
}
Original file line number Diff line number Diff line change @@ -83,6 +83,26 @@ describe('drop/drop', function () {
83
83
const html = await liquid . parseAndRender ( tpl , { address, customer } )
84
84
expect ( html ) . toBe ( 'test' )
85
85
} )
86
+ it ( 'should correctly evaluate custom Drop objects with equals function without full Comparable implementation' , async ( ) => {
87
+ class TestDrop extends Drop {
88
+ value : string ;
89
+ constructor ( ) {
90
+ super ( )
91
+ this . value = 'test'
92
+ }
93
+ equals ( rhs : string ) : boolean {
94
+ return this . valueOf ( ) === rhs
95
+ }
96
+ valueOf ( ) : string {
97
+ return this . value
98
+ }
99
+ }
100
+ const address = new TestDrop ( )
101
+ const customer = { default_address : new TestDrop ( ) }
102
+ const tpl = `{{ address >= customer.default_address }}`
103
+ const html = await liquid . parseAndRender ( tpl , { address, customer } )
104
+ expect ( html ) . toBe ( 'true' )
105
+ } )
86
106
it ( 'should support returning supported value types from liquidMethodMissing' , async function ( ) {
87
107
class DynamicTypeDrop extends Drop {
88
108
liquidMethodMissing ( key : string ) {
You can’t perform that action at this time.
0 commit comments