@@ -2,11 +2,11 @@ import chai from "chai";
2
2
import chaiAsPromised from "chai-as-promised"
3
3
chai . use ( chaiAsPromised ) ;
4
4
const expect = chai . expect ;
5
- import { PkceCodes , SPAClient , NetworkRequestOptions , LogLevel , Account , TokenResponse , CodeResponse } from "@azure/msal-common" ;
5
+ import { PkceCodes , SPAClient , NetworkRequestOptions , LogLevel , InMemoryCache } from "@azure/msal-common" ;
6
6
import { PopupHandler } from "../../src/interaction_handler/PopupHandler" ;
7
7
import { BrowserStorage } from "../../src/cache/BrowserStorage" ;
8
8
import { Configuration , buildConfiguration } from "../../src/config/Configuration" ;
9
- import { TEST_CONFIG , TEST_TOKENS , TEST_TOKEN_LIFETIMES , TEST_DATA_CLIENT_INFO , TEST_URIS , RANDOM_TEST_GUID , TEST_HASHES } from "../utils/StringConstants" ;
9
+ import { TEST_CONFIG , TEST_URIS } from "../utils/StringConstants" ;
10
10
import sinon from "sinon" ;
11
11
import { InteractionHandler } from "../../src/interaction_handler/InteractionHandler" ;
12
12
import { BrowserAuthErrorMessage , BrowserAuthError } from "../../src/error/BrowserAuthError" ;
@@ -50,8 +50,9 @@ describe("PopupHandler.ts Unit Tests", () => {
50
50
const authCodeModule = new SPAClient ( {
51
51
authOptions : configObj . auth ,
52
52
systemOptions : {
53
- tokenRenewalOffsetSeconds : configObj . system . tokenRenewalOffsetSeconds ,
54
- telemetry : configObj . system . telemetry
53
+ tokenRenewalOffsetSeconds :
54
+ configObj . system . tokenRenewalOffsetSeconds ,
55
+ telemetry : configObj . system . telemetry ,
55
56
} ,
56
57
cryptoInterface : {
57
58
createNewGuid : ( ) : string => {
@@ -65,9 +66,21 @@ describe("PopupHandler.ts Unit Tests", () => {
65
66
} ,
66
67
generatePkceCodes : async ( ) : Promise < PkceCodes > => {
67
68
return testPkceCodes ;
68
- }
69
+ } ,
69
70
} ,
70
71
storageInterface : {
72
+ getCache : ( ) : InMemoryCache => {
73
+ return {
74
+ accounts : { } ,
75
+ idTokens : { } ,
76
+ accessTokens : { } ,
77
+ refreshTokens : { } ,
78
+ appMetadata : { } ,
79
+ } ;
80
+ } ,
81
+ setCache : ( ) : void => {
82
+ // dummy impl;
83
+ } ,
71
84
clear : clearFunc ,
72
85
containsKey : ( key : string ) : boolean => {
73
86
return true ;
@@ -79,24 +92,34 @@ describe("PopupHandler.ts Unit Tests", () => {
79
92
return testKeySet ;
80
93
} ,
81
94
removeItem : removeFunc ,
82
- setItem : setFunc
95
+ setItem : setFunc ,
83
96
} ,
84
97
networkInterface : {
85
- sendGetRequestAsync : async ( url : string , options ?: NetworkRequestOptions ) : Promise < any > => {
98
+ sendGetRequestAsync : async (
99
+ url : string ,
100
+ options ?: NetworkRequestOptions
101
+ ) : Promise < any > => {
86
102
return testNetworkResult ;
87
103
} ,
88
- sendPostRequestAsync : async ( url : string , options ?: NetworkRequestOptions ) : Promise < any > => {
104
+ sendPostRequestAsync : async (
105
+ url : string ,
106
+ options ?: NetworkRequestOptions
107
+ ) : Promise < any > => {
89
108
return testNetworkResult ;
90
- }
109
+ } ,
91
110
} ,
92
111
loggerOptions : {
93
- loggerCallback : ( level : LogLevel , message : string , containsPii : boolean ) : void => {
112
+ loggerCallback : (
113
+ level : LogLevel ,
114
+ message : string ,
115
+ containsPii : boolean
116
+ ) : void => {
94
117
if ( containsPii ) {
95
118
console . log ( `Log level: ${ level } Message: ${ message } ` ) ;
96
119
}
97
120
} ,
98
- piiLoggingEnabled : true
99
- }
121
+ piiLoggingEnabled : true ,
122
+ } ,
100
123
} ) ;
101
124
browserStorage = new BrowserStorage ( TEST_CONFIG . MSAL_CLIENT_ID , configObj . cache ) ;
102
125
popupHandler = new PopupHandler ( authCodeModule , browserStorage ) ;
0 commit comments