@@ -26,16 +26,12 @@ describe('browser local storage cache', () => {
26
26
const cache = createBrowserLocalStorageCache ( { key : version } ) ;
27
27
const defaultValue = ( ) : DefaultValue => Promise . resolve ( { bar : 1 } ) ;
28
28
29
- expect ( await cache . get ( { key : 'foo' } , defaultValue , events ) ) . toMatchObject (
30
- { bar : 1 }
31
- ) ;
29
+ expect ( await cache . get ( { key : 'foo' } , defaultValue , events ) ) . toMatchObject ( { bar : 1 } ) ;
32
30
expect ( missMock . mock . calls . length ) . toBe ( 1 ) ;
33
31
34
32
await cache . set ( { key : 'foo' } , { foo : 2 } ) ;
35
33
36
- expect ( await cache . get ( { key : 'foo' } , defaultValue , events ) ) . toMatchObject (
37
- { foo : 2 }
38
- ) ;
34
+ expect ( await cache . get ( { key : 'foo' } , defaultValue , events ) ) . toMatchObject ( { foo : 2 } ) ;
39
35
expect ( missMock . mock . calls . length ) . toBe ( 1 ) ;
40
36
} ) ;
41
37
@@ -51,7 +47,7 @@ describe('browser local storage cache', () => {
51
47
expect (
52
48
await cache . get ( { key : 'foo' } , defaultValue , {
53
49
miss : ( ) => Promise . resolve ( missMock ( ) ) ,
54
- } )
50
+ } ) ,
55
51
) . toMatchObject ( { bar : 1 } ) ;
56
52
57
53
expect ( missMock . mock . calls . length ) . toBe ( 0 ) ;
@@ -65,9 +61,7 @@ describe('browser local storage cache', () => {
65
61
66
62
const defaultValue = ( ) : DefaultValue => Promise . resolve ( { bar : 2 } ) ;
67
63
68
- expect ( await cache . get ( { key : 'foo' } , defaultValue , events ) ) . toMatchObject (
69
- { bar : 2 }
70
- ) ;
64
+ expect ( await cache . get ( { key : 'foo' } , defaultValue , events ) ) . toMatchObject ( { bar : 2 } ) ;
71
65
expect ( missMock . mock . calls . length ) . toBe ( 1 ) ;
72
66
} ) ;
73
67
@@ -83,7 +77,7 @@ describe('browser local storage cache', () => {
83
77
expect (
84
78
await cache . get ( { key : 'foo' } , defaultValue , {
85
79
miss : ( ) => Promise . resolve ( missMock ( ) ) ,
86
- } )
80
+ } ) ,
87
81
) . toMatchObject ( { bar : 2 } ) ;
88
82
89
83
expect ( missMock . mock . calls . length ) . toBe ( 1 ) ;
@@ -102,7 +96,7 @@ describe('browser local storage cache', () => {
102
96
expect (
103
97
await cache . get ( { key : 'foo' } , defaultValue , {
104
98
miss : ( ) => Promise . resolve ( missMock ( ) ) ,
105
- } )
99
+ } ) ,
106
100
) . toMatchObject ( { bar : 2 } ) ;
107
101
108
102
expect ( missMock . mock . calls . length ) . toBe ( 1 ) ;
@@ -111,8 +105,7 @@ describe('browser local storage cache', () => {
111
105
} ) ;
112
106
113
107
it ( 'do throws localstorage exceptions on access' , async ( ) => {
114
- const message =
115
- "Failed to read the 'localStorage' property from 'Window': Access is denied for this document." ;
108
+ const message = "Failed to read the 'localStorage' property from 'Window': Access is denied for this document." ;
116
109
const cache = createBrowserLocalStorageCache (
117
110
new Proxy (
118
111
{ key : 'foo' } ,
@@ -125,20 +118,16 @@ describe('browser local storage cache', () => {
125
118
// Simulates a window.localStorage access.
126
119
throw new DOMException ( message ) ;
127
120
} ,
128
- }
129
- )
121
+ } ,
122
+ ) ,
130
123
) ;
131
124
const key = { foo : 'bar' } ;
132
125
const value = 'foo' ;
133
126
const fallback = 'bar' ;
134
127
135
128
await expect ( cache . delete ( key ) ) . rejects . toEqual ( new DOMException ( message ) ) ;
136
- await expect ( cache . set ( key , value ) ) . rejects . toEqual (
137
- new DOMException ( message )
138
- ) ;
139
- await expect (
140
- cache . get ( key , ( ) => Promise . resolve ( fallback ) )
141
- ) . rejects . toEqual ( new DOMException ( message ) ) ;
129
+ await expect ( cache . set ( key , value ) ) . rejects . toEqual ( new DOMException ( message ) ) ;
130
+ await expect ( cache . get ( key , ( ) => Promise . resolve ( fallback ) ) ) . rejects . toEqual ( new DOMException ( message ) ) ;
142
131
} ) ;
143
132
144
133
it ( 'do throws localstorage exceptions after access' , async ( ) => {
@@ -153,9 +142,7 @@ describe('browser local storage cache', () => {
153
142
154
143
await expect ( cache . delete ( key ) ) . rejects . toEqual ( new Error ( message ) ) ;
155
144
await expect ( cache . set ( key , value ) ) . rejects . toEqual ( new Error ( message ) ) ;
156
- await expect (
157
- cache . get ( key , ( ) => Promise . resolve ( fallback ) )
158
- ) . rejects . toEqual ( new Error ( message ) ) ;
145
+ await expect ( cache . get ( key , ( ) => Promise . resolve ( fallback ) ) ) . rejects . toEqual ( new Error ( message ) ) ;
159
146
} ) ;
160
147
161
148
it ( 'creates a namespace within local storage' , async ( ) => {
@@ -175,12 +162,8 @@ describe('browser local storage cache', () => {
175
162
} ,
176
163
} ) ;
177
164
178
- const localStorageValue = localStorage . getItem (
179
- `algolia-client-js-${ version } `
180
- ) ;
165
+ const localStorageValue = localStorage . getItem ( `algolia-client-js-${ version } ` ) ;
181
166
182
- expect ( JSON . parse ( localStorageValue ? localStorageValue : '{}' ) ) . toEqual (
183
- expectedValue
184
- ) ;
167
+ expect ( JSON . parse ( localStorageValue ? localStorageValue : '{}' ) ) . toEqual ( expectedValue ) ;
185
168
} ) ;
186
169
} ) ;
0 commit comments