@@ -71,7 +71,6 @@ describe('LiquidOptions#cache', function () {
71
71
extname : '.html' ,
72
72
cache : {
73
73
read : ( ) : Template [ ] | undefined => last ,
74
- has : ( ) : boolean => ! ! last ,
75
74
write : ( key : string , value : Template [ ] ) => { last = value }
76
75
}
77
76
} )
@@ -82,6 +81,25 @@ describe('LiquidOptions#cache', function () {
82
81
expect ( await engine . renderFile ( 'files/bar' ) ) . to . equal ( 'foo' )
83
82
expect ( await engine . renderFile ( 'files/coo' ) ) . to . equal ( 'foo' )
84
83
} )
84
+ it ( 'should respect cache={} option (async)' , async function ( ) {
85
+ const cached : { [ key : string ] : Template [ ] | undefined } = { }
86
+ const engine = new Liquid ( {
87
+ root : '/root/' ,
88
+ extname : '.html' ,
89
+ cache : {
90
+ read : ( key : string ) => Promise . resolve ( cached [ key ] ) ,
91
+ write : ( key : string , value : Template [ ] ) => { cached [ key ] = value ; Promise . resolve ( ) }
92
+ }
93
+ } )
94
+ mock ( { '/root/files/foo.html' : 'foo' } )
95
+ mock ( { '/root/files/bar.html' : 'bar' } )
96
+ mock ( { '/root/files/coo.html' : 'coo' } )
97
+ expect ( await engine . renderFile ( 'files/foo' ) ) . to . equal ( 'foo' )
98
+ expect ( await engine . renderFile ( 'files/bar' ) ) . to . equal ( 'bar' )
99
+ expect ( await engine . renderFile ( 'files/coo' ) ) . to . equal ( 'coo' )
100
+ mock ( { '/root/files/coo.html' : 'COO' } )
101
+ expect ( await engine . renderFile ( 'files/coo' ) ) . to . equal ( 'coo' )
102
+ } )
85
103
it ( 'should not cache not exist file' , async function ( ) {
86
104
const engine = new Liquid ( {
87
105
root : '/root/' ,
0 commit comments