Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bferenc committed Dec 16, 2024
1 parent a872e40 commit 220306f
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/background/runtime/BackgroundRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class BackgroundRuntime {
// we try to fetch the bridge configs as soon as possible
private bridgeService: BridgeService,
private moduleManager: ModuleManager,
private appCheckService: AppCheckService
private appCheckService: AppCheckService,
) {}

activate() {
Expand Down
16 changes: 8 additions & 8 deletions src/background/services/appcheck/AppCheckService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ describe('AppCheckService', () => {
it('subscribes for events on activation correctly', () => {
expect(firebaseService.addFcmMessageListener).toHaveBeenCalledWith(
FcmMessageEvents.ID_CHALLENGE,
expect.any(Function)
expect.any(Function),
);

expect(firebaseService.addFirebaseEventListener).toHaveBeenCalledTimes(2);
expect(firebaseService.addFirebaseEventListener).toHaveBeenNthCalledWith(
1,
FirebaseEvents.FCM_INITIALIZED,
expect.any(Function)
expect.any(Function),
);
expect(firebaseService.addFirebaseEventListener).toHaveBeenNthCalledWith(
2,
FirebaseEvents.FCM_TERMINATED,
expect.any(Function)
expect.any(Function),
);
});

Expand All @@ -81,7 +81,7 @@ describe('AppCheckService', () => {
{
provider: expect.any(CustomProvider),
isTokenAutoRefreshEnabled: true,
}
},
);

// simulate FCM_INITIALIZED event (second time)
Expand All @@ -98,15 +98,15 @@ describe('AppCheckService', () => {
{
provider: expect.any(CustomProvider),
isTokenAutoRefreshEnabled: true,
}
},
);

// simulate FCM_TERMINATED event
jest.mocked(firebaseService.addFirebaseEventListener).mock.calls[1]?.[1]();

expect(setTokenAutoRefreshEnabled).toHaveBeenCalledWith(
appCheckMock,
false
false,
);
});

Expand All @@ -116,14 +116,14 @@ describe('AppCheckService', () => {
// @ts-ignore
firebaseService.isFcmInitialized = false;
await expect(
jest.mocked(CustomProvider).mock.calls[0]?.[0].getToken()
jest.mocked(CustomProvider).mock.calls[0]?.[0].getToken(),
).rejects.toThrow('fcm is not initialized');
});

it('throws when FCM token is missing', async () => {
jest.mocked(firebaseService.getFcmToken).mockReturnValueOnce(undefined);
await expect(
jest.mocked(CustomProvider).mock.calls[0]?.[0].getToken()
jest.mocked(CustomProvider).mock.calls[0]?.[0].getToken(),
).rejects.toThrow('fcm token is missing');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('basic', () => {

it('throws when params are incorrect', () => {
expect(() => solveBasicChallenge('{}')).toThrow(
'invalid basic challenge details'
'invalid basic challenge details',
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ describe('getHashByAlgorithm', () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
expect(() => getHashByAlgorithm('unknown', 'core')).toThrow(
'unsupported algorithm "unknown"'
'unsupported algorithm "unknown"',
);
});

it.each(Object.entries(cases))(
'uses the correct algorithm',
(algorithm, expected) => {
expect(getHashByAlgorithm(algorithm as Algorithm, 'core')).toBe(expected);
}
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('registerForChallenge', () => {
delete process.env.ID_SERVICE_URL;

expect(registerForChallenge(params)).rejects.toThrow(
'ID_SERVICE_URL is missing'
'ID_SERVICE_URL is missing',
);
});

Expand All @@ -38,7 +38,7 @@ describe('registerForChallenge', () => {
} as Response);

expect(registerForChallenge(params)).rejects.toThrow(
'challenge registration error: "internal error"'
'challenge registration error: "internal error"',
);
});

Expand All @@ -64,7 +64,7 @@ describe('registerForChallenge', () => {
token: 'token',
requestId: 'requestId',
}),
}
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const registerForChallenge = async ({ token, requestId }: Params) => {

if (!registerResponse.ok) {
throw new Error(
`challenge registration error: "${registerResponse.statusText}"`
`challenge registration error: "${registerResponse.statusText}"`,
);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('solveChallenge', () => {

it('solves basic challenges correctly', async () => {
expect(
solveChallenge({ type: ChallengeTypes.BASIC, challengeDetails })
solveChallenge({ type: ChallengeTypes.BASIC, challengeDetails }),
).resolves.toBe(solution);
expect(solveBasicChallenge).toHaveBeenCalledWith(challengeDetails);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('verifyChallenge', () => {
delete process.env.ID_SERVICE_URL;

expect(verifyChallenge(params)).rejects.toThrow(
'ID_SERVICE_URL is missing'
'ID_SERVICE_URL is missing',
);
});

Expand All @@ -38,7 +38,7 @@ describe('verifyChallenge', () => {
} as Response);

expect(verifyChallenge(params)).rejects.toThrow(
'challenge verification error: "internal error"'
'challenge verification error: "internal error"',
);
});

Expand Down
2 changes: 1 addition & 1 deletion src/background/services/appcheck/utils/verifyChallenge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const verifyChallenge = async ({ registrationId, solution }: Params) => {

if (!verifyChallengeResponse.ok) {
throw new Error(
`challenge verification error: "${verifyChallengeResponse.statusText}"`
`challenge verification error: "${verifyChallengeResponse.statusText}"`,
);
}

Expand Down
20 changes: 10 additions & 10 deletions src/background/services/firebase/FirebaseService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('FirebaseService', () => {
process.env = {
...realEnv,
FIREBASE_CONFIG: Buffer.from(JSON.stringify({ foo: 'bar' })).toString(
'base64'
'base64',
),
};
});
Expand All @@ -48,7 +48,7 @@ describe('FirebaseService', () => {
delete process.env.FIREBASE_CONFIG;

expect(() => new FirebaseService(featureFlagService)).toThrow(
'FIREBASE_CONFIG is missing'
'FIREBASE_CONFIG is missing',
);
});

Expand All @@ -62,11 +62,11 @@ describe('FirebaseService', () => {
expect(getMessaging).toHaveBeenCalledWith(appMock);
expect(onBackgroundMessage).toHaveBeenCalledWith(
messagingMock,
expect.any(Function)
expect.any(Function),
);
expect(featureFlagService.addListener).toHaveBeenCalledWith(
FeatureFlagEvents.FEATURE_FLAG_UPDATED,
expect.any(Function)
expect.any(Function),
);
});

Expand All @@ -83,14 +83,14 @@ describe('FirebaseService', () => {

firebaseService.addFirebaseEventListener(
FirebaseEvents.FCM_INITIALIZED,
initializedEventListener
initializedEventListener,
);

// simulate FEATURE_FLAG_UPDATED event
await expect(
jest.mocked(featureFlagService.addListener).mock.calls[0]?.[1]({
[FeatureGates.FIREBASE_CLOUD_MESSAGING]: true,
} as FeatureFlags)
} as FeatureFlags),
).resolves.toBeUndefined();

expect(firebaseService.isFcmInitialized).toBe(true);
Expand All @@ -108,21 +108,21 @@ describe('FirebaseService', () => {

firebaseService.addFirebaseEventListener(
FirebaseEvents.FCM_TERMINATED,
terminatedEventListener
terminatedEventListener,
);

// simulate FEATURE_FLAG_UPDATED event (enabled)
await expect(
jest.mocked(featureFlagService.addListener).mock.calls[0]?.[1]({
[FeatureGates.FIREBASE_CLOUD_MESSAGING]: true,
} as FeatureFlags)
} as FeatureFlags),
).resolves.toBeUndefined();

// simulate FEATURE_FLAG_UPDATED event (disabled)
await expect(
jest.mocked(featureFlagService.addListener).mock.calls[0]?.[1]({
[FeatureGates.FIREBASE_CLOUD_MESSAGING]: false,
} as FeatureFlags)
} as FeatureFlags),
).resolves.toBeUndefined();

expect(firebaseService.isFcmInitialized).toBe(false);
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('FirebaseService', () => {

expect(eventListener).toHaveBeenCalledTimes(1);
expect(eventListener).toHaveBeenCalledWith(messageMock);
}
},
);
});
});
6 changes: 3 additions & 3 deletions src/background/services/firebase/FirebaseService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class FirebaseService {
}

this.#app = initializeApp(
JSON.parse(Buffer.from(process.env.FIREBASE_CONFIG, 'base64').toString())
JSON.parse(Buffer.from(process.env.FIREBASE_CONFIG, 'base64').toString()),
);

onBackgroundMessage(getMessaging(this.#app), (payload) => {
Expand Down Expand Up @@ -66,7 +66,7 @@ export class FirebaseService {
} catch (err) {
sentryCaptureException(err as Error, SentryExceptionTypes.FIREBASE);
}
}
},
);
}

Expand All @@ -84,7 +84,7 @@ export class FirebaseService {

addFirebaseEventListener<T = unknown>(
event: FirebaseEvents,
callback: () => T
callback: () => T,
) {
this.#firebaseEventEmitter.on(event, callback);
}
Expand Down
2 changes: 1 addition & 1 deletion src/background/services/firebase/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ export enum FcmMessageEvents {
}

export type FcmMessageListener = (
payload: MessagePayload
payload: MessagePayload,
) => unknown | Promise<unknown>;

0 comments on commit 220306f

Please sign in to comment.