Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1593,24 +1593,6 @@
"count": 70
}
},
"packages/notification-services-controller/src/NotificationServicesPushController/NotificationServicesPushController.test.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 4
},
"@typescript-eslint/prefer-nullish-coalescing": {
"count": 1
}
},
"packages/notification-services-controller/src/NotificationServicesPushController/NotificationServicesPushController.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 6
}
},
"packages/notification-services-controller/src/NotificationServicesPushController/__fixtures__/mockServices.ts": {
"@typescript-eslint/explicit-function-return-type": {
"count": 1
}
},
"packages/notification-services-controller/src/NotificationServicesPushController/services/services.ts": {
"@typescript-eslint/naming-convention": {
"count": 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ const MOCK_FCM_TOKEN = 'mockFcmToken';
const MOCK_ADDRESSES = ['0x123', '0x456', '0x789'];

// Testing util to clean up verbose logs when testing errors
const mockErrorLog = () =>
const mockErrorLog = (): jest.SpyInstance =>
jest.spyOn(log, 'error').mockImplementation(jest.fn());

describe('NotificationServicesPushController', () => {
const arrangeServicesMocks = (token?: string) => {
const arrangeServicesMocks = (
token?: string,
): {
activatePushNotificationsMock: jest.SpyInstance;
deactivatePushNotificationsMock: jest.SpyInstance;
} => {
const activatePushNotificationsMock = jest
.spyOn(services, 'activatePushNotifications')
.mockResolvedValue(token ?? MOCK_FCM_TOKEN);
Expand Down Expand Up @@ -359,8 +364,12 @@ function arrangeMockMessenger(
state?: Partial<NotificationServicesPushController['state']>;
}
>,
) {
const { state: stateOverride, ...configOverride } = controllerConfig || {};
): {
controller: NotificationServicesPushController;
initialState: NotificationServicesPushController['state'];
messenger: NotificationServicesPushControllerMessenger;
} {
const { state: stateOverride, ...configOverride } = controllerConfig ?? {};

const config: ControllerConfig = {
isPushFeatureEnabled: true,
Expand Down Expand Up @@ -403,7 +412,14 @@ function arrangeMockMessenger(
*/
function mockAuthBearerTokenCall(
messenger: NotificationServicesPushControllerMessenger,
) {
): jest.Mock<
ReturnType<
AuthenticationController.AuthenticationControllerGetBearerToken['handler']
>,
Parameters<
AuthenticationController.AuthenticationControllerGetBearerToken['handler']
>
> {
type Fn =
AuthenticationController.AuthenticationControllerGetBearerToken['handler'];
const mockAuthGetBearerToken = jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export default class NotificationServicesPushController extends BaseController<
});
}

async #getAndAssertBearerToken() {
async #getAndAssertBearerToken(): Promise<string> {
const bearerToken = await this.messenger.call(
'AuthenticationController:getBearerToken',
);
Expand All @@ -239,7 +239,7 @@ export default class NotificationServicesPushController extends BaseController<
return bearerToken;
}

#updatePushState(command: StateCommand) {
#updatePushState(command: StateCommand): void {
if (command.type === 'enable') {
this.update((state) => {
state.isPushEnabled = true;
Expand All @@ -266,7 +266,7 @@ export default class NotificationServicesPushController extends BaseController<
}
}

public async subscribeToPushNotifications() {
public async subscribeToPushNotifications(): Promise<void> {
if (!this.#config.isPushFeatureEnabled) {
return;
}
Expand Down Expand Up @@ -296,7 +296,7 @@ export default class NotificationServicesPushController extends BaseController<
*
* @param addresses - An array of addresses to enable push notifications for.
*/
public async enablePushNotifications(addresses: string[]) {
public async enablePushNotifications(addresses: string[]): Promise<void> {
if (!this.#config.isPushFeatureEnabled) {
return;
}
Expand Down Expand Up @@ -351,7 +351,7 @@ export default class NotificationServicesPushController extends BaseController<
* Disables push notifications for the application.
* This removes the registration token on this device, and ensures we unsubscribe from any listeners
*/
public async disablePushNotifications() {
public async disablePushNotifications(): Promise<void> {
if (!this.#config.isPushFeatureEnabled) {
return;
}
Expand Down Expand Up @@ -394,7 +394,9 @@ export default class NotificationServicesPushController extends BaseController<
* @param addresses - An array of addresses that should trigger push notifications.
* @deprecated - this is not used anymore and will most likely be removed
*/
public async updateTriggerPushNotifications(addresses: string[]) {
public async updateTriggerPushNotifications(
addresses: string[],
): Promise<void> {
if (!this.#config.isPushFeatureEnabled) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type MockReply = {

export const mockEndpointUpdatePushNotificationLinks = (
mockReply?: MockReply,
) => {
): nock.Scope => {
const mockResponse = getMockUpdatePushNotificationLinksResponse();
const reply = mockReply ?? {
status: 204,
Expand Down
Loading