File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,12 @@ export interface Comparable {
99}
1010
1111export 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+ )
1320}
Original file line number Diff line number Diff line change @@ -83,6 +83,26 @@ describe('drop/drop', function () {
8383 const html = await liquid . parseAndRender ( tpl , { address, customer } )
8484 expect ( html ) . toBe ( 'test' )
8585 } )
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+ } )
86106 it ( 'should support returning supported value types from liquidMethodMissing' , async function ( ) {
87107 class DynamicTypeDrop extends Drop {
88108 liquidMethodMissing ( key : string ) {
You can’t perform that action at this time.
0 commit comments