File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ var NullCacheAdapter = require ( '../src/Adapters/Cache/NullCacheAdapter' ) . default ;
2
+
3
+ describe ( 'NullCacheAdapter' , function ( ) {
4
+ var KEY = 'hello' ;
5
+ var VALUE = 'world' ;
6
+
7
+ it ( 'should expose promisifyed methods' , ( done ) => {
8
+ var cache = new NullCacheAdapter ( {
9
+ ttl : NaN
10
+ } ) ;
11
+
12
+ // Verify all methods return promises.
13
+ Promise . all ( [
14
+ cache . put ( KEY , VALUE ) ,
15
+ cache . del ( KEY ) ,
16
+ cache . get ( KEY ) ,
17
+ cache . clear ( )
18
+ ] ) . then ( ( ) => {
19
+ done ( ) ;
20
+ } ) ;
21
+ } ) ;
22
+
23
+ it ( 'should get/set/clear' , ( done ) => {
24
+ var cache = new NullCacheAdapter ( {
25
+ ttl : NaN
26
+ } ) ;
27
+
28
+ cache . put ( KEY , VALUE )
29
+ . then ( ( ) => cache . get ( KEY ) )
30
+ . then ( ( value ) => expect ( value ) . toEqual ( null ) )
31
+ . then ( ( ) => cache . clear ( ) )
32
+ . then ( ( ) => cache . get ( KEY ) )
33
+ . then ( ( value ) => expect ( value ) . toEqual ( null ) )
34
+ . then ( done ) ;
35
+ } ) ;
36
+
37
+ } ) ;
Original file line number Diff line number Diff line change
1
+ export class NullCacheAdapter {
2
+
3
+ constructor ( ctx ) {
4
+ }
5
+
6
+ get ( key ) {
7
+ return new Promise ( ( resolve , _ ) => {
8
+ return resolve ( null ) ;
9
+ } )
10
+ }
11
+
12
+ put ( key , value , ttl ) {
13
+ return Promise . resolve ( ) ;
14
+ }
15
+
16
+ del ( key ) {
17
+ return Promise . resolve ( ) ;
18
+ }
19
+
20
+ clear ( ) {
21
+ }
22
+ }
23
+
24
+ export default NullCacheAdapter ;
You can’t perform that action at this time.
0 commit comments