@@ -133,13 +133,29 @@ describe("BrowserStorage() tests", () => {
133
133
expect ( window . localStorage . getItem ( msalCacheKey ) ) . to . be . eq ( cacheVal ) ;
134
134
} ) ;
135
135
136
+ it ( "setItem() throws error if type passed in is not one of CacheSchemaType types" , ( ) => {
137
+ expect ( ( ) => browserSessionStorage . setItem ( msalCacheKey , cacheVal , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthError ) ;
138
+ expect ( ( ) => browserSessionStorage . setItem ( msalCacheKey , cacheVal , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthErrorMessage . invalidCacheType . desc ) ;
139
+ expect ( ( ) => browserLocalStorage . setItem ( msalCacheKey , cacheVal , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthError ) ;
140
+ expect ( ( ) => browserLocalStorage . setItem ( msalCacheKey , cacheVal , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthErrorMessage . invalidCacheType . desc ) ;
141
+ } ) ;
142
+
136
143
it ( "getItem()" , ( ) => {
137
144
window . sessionStorage . setItem ( msalCacheKey , cacheVal ) ;
138
145
window . localStorage . setItem ( msalCacheKey , cacheVal ) ;
139
146
expect ( browserSessionStorage . getItem ( msalCacheKey , CacheSchemaType . TEMPORARY ) ) . to . be . eq ( cacheVal ) ;
140
147
expect ( browserLocalStorage . getItem ( msalCacheKey , CacheSchemaType . TEMPORARY ) ) . to . be . eq ( cacheVal ) ;
141
148
} ) ;
142
149
150
+ it ( "getItem() throws error if type passed in is not one of CacheSchemaType types" , ( ) => {
151
+ window . sessionStorage . setItem ( msalCacheKey , cacheVal ) ;
152
+ window . localStorage . setItem ( msalCacheKey , cacheVal ) ;
153
+ expect ( ( ) => browserSessionStorage . getItem ( msalCacheKey , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthError ) ;
154
+ expect ( ( ) => browserSessionStorage . getItem ( msalCacheKey , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthErrorMessage . invalidCacheType . desc ) ;
155
+ expect ( ( ) => browserLocalStorage . getItem ( msalCacheKey , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthError ) ;
156
+ expect ( ( ) => browserLocalStorage . getItem ( msalCacheKey , "OTHER_TYPE" ) ) . to . throw ( BrowserAuthErrorMessage . invalidCacheType . desc ) ;
157
+ } ) ;
158
+
143
159
it ( "removeItem()" , ( ) => {
144
160
browserSessionStorage . setItem ( msalCacheKey , cacheVal , CacheSchemaType . TEMPORARY ) ;
145
161
browserLocalStorage . setItem ( msalCacheKey , cacheVal , CacheSchemaType . TEMPORARY ) ;
0 commit comments