@@ -19,7 +19,10 @@ const mockUser: User = {
1919
2020describe ( 'setupIntercom' , function ( ) {
2121 let backupEnv : Partial < typeof process . env > ;
22- let fetchMock : SinonStub ;
22+ let fetchMock : SinonStub <
23+ Parameters < typeof globalThis . fetch > ,
24+ ReturnType < typeof globalThis . fetch >
25+ > ;
2326 let preferences : PreferencesAccess ;
2427
2528 async function testRunSetupIntercom ( ) {
@@ -47,11 +50,7 @@ describe('setupIntercom', function () {
4750 process . env . HADRON_APP_VERSION = 'v0.0.0-test.123' ;
4851 process . env . NODE_ENV = 'test' ;
4952 process . env . HADRON_METRICS_INTERCOM_APP_ID = 'appid123' ;
50- fetchMock = sinon . stub ( ) ;
51- window . fetch = fetchMock ;
52- // NOTE: we use 301 since intercom will redirects
53- // to the actual location of the widget script
54- fetchMock . resolves ( { status : 301 } as Response ) ;
53+ fetchMock = sinon . stub ( globalThis , 'fetch' ) ;
5554 preferences = await createSandboxFromDefaultPreferences ( ) ;
5655 await preferences . savePreferences ( {
5756 enableFeedbackPanel : true ,
@@ -66,7 +65,7 @@ describe('setupIntercom', function () {
6665 process . env . HADRON_PRODUCT_NAME = backupEnv . HADRON_PRODUCT_NAME as any ;
6766 process . env . HADRON_APP_VERSION = backupEnv . HADRON_APP_VERSION as any ;
6867 process . env . NODE_ENV = backupEnv . NODE_ENV ;
69- fetchMock . reset ( ) ;
68+ fetchMock . restore ( ) ;
7069 } ) ;
7170
7271 describe ( 'when it can be enabled' , function ( ) {
0 commit comments