File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
packages/shared/sdk-server Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -46,14 +46,19 @@ it('when it has been cleared', () => {
4646 expect ( lruCache . get ( i . toString ( ) ) ) . toBeUndefined ( ) ;
4747 }
4848
49- // Fill the cache with integers again .
49+ // Fill the cache with integers in a different range .
5050 for ( let i = 0 ; i < max ; i += 1 ) {
51- lruCache . set ( `${ i } ` , i ) ;
51+ lruCache . set ( `${ i + 100 } ` , i ) ;
5252 }
5353
5454 // Check they are all there.
5555 for ( let i = 0 ; i < max ; i += 1 ) {
56- expect ( lruCache . get ( i . toString ( ) ) ) . toEqual ( i ) ;
56+ expect ( lruCache . get ( `${ i + 100 } ` ) ) . toEqual ( i ) ;
57+ }
58+
59+ // Check old keys don't associate with new values.
60+ for ( let i = 0 ; i < max ; i += 1 ) {
61+ expect ( lruCache . get ( i . toString ( ) ) ) . toBeUndefined ( ) ;
5762 }
5863} ) ;
5964
Original file line number Diff line number Diff line change @@ -110,6 +110,7 @@ export default class LruCache {
110110 this . keys . fill ( undefined ) ;
111111 this . next . fill ( 0 ) ;
112112 this . prev . fill ( 0 ) ;
113+ this . keyMap . clear ( ) ;
113114 }
114115
115116 private index ( ) {
You can’t perform that action at this time.
0 commit comments