From 7ccbf598e5691ad3e156ad0b0d01437dc2bdb94b Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Fri, 20 Sep 2024 21:35:24 +0100 Subject: [PATCH 1/2] fix: try converting async arrow functions into async functions --- .../__fixtures__/mockResponses.ts | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts index 94e9229215..120332219d 100644 --- a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts +++ b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts @@ -33,43 +33,70 @@ export const getMockUserStorageEndpoint = ( )}`; }; -export const createMockGetStorageResponse = async ( +/** + * Temp + * @param data - foo + * @returns bar + */ +export async function createMockGetStorageResponse( data?: string, -): Promise => ({ - HashedKey: 'HASHED_KEY', - Data: await MOCK_ENCRYPTED_STORAGE_DATA(data), -}); +): Promise { + return { + HashedKey: 'HASHED_KEY', + Data: await MOCK_ENCRYPTED_STORAGE_DATA(data), + }; +} -export const createMockAllFeatureEntriesResponse = async ( +/** + * Temp + * @param dataArr - foo + * @returns bar + */ +export async function createMockAllFeatureEntriesResponse( dataArr: string[] = [MOCK_STORAGE_DATA], -): Promise => - Promise.all( - dataArr.map(async (d) => ({ - HashedKey: 'HASHED_KEY', - Data: await MOCK_ENCRYPTED_STORAGE_DATA(d), - })), +): Promise { + return await Promise.all( + dataArr.map(async function (d) { + const encryptedData = await MOCK_ENCRYPTED_STORAGE_DATA(d); + return { + HashedKey: 'HASHED_KEY', + Data: encryptedData, + }; + }), ); +} -export const getMockUserStorageGetResponse = async ( +/** + * Temp + * @param path - foo + * @returns bar + */ +export async function getMockUserStorageGetResponse( path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings', -) => { +) { return { url: getMockUserStorageEndpoint(path), requestMethod: 'GET', response: await createMockGetStorageResponse(), } satisfies MockResponse; -}; +} -export const getMockUserStorageAllFeatureEntriesResponse = async ( +/** + * Temp + * @param path - foo + * @param dataArr - bar + * @returns baz + */ +export async function getMockUserStorageAllFeatureEntriesResponse( path: UserStoragePathWithFeatureOnly = 'notifications', dataArr?: string[], -) => { +) { return { url: getMockUserStorageEndpoint(path), requestMethod: 'GET', response: await createMockAllFeatureEntriesResponse(dataArr), } satisfies MockResponse; -}; +} export const getMockUserStoragePutResponse = ( path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings', From 4c593387737764f04eedea18a632d32312a6390e Mon Sep 17 00:00:00 2001 From: Prithpal Sooriya Date: Fri, 20 Sep 2024 22:29:20 +0100 Subject: [PATCH 2/2] docs: update JSDoc comments --- .../__fixtures__/mockResponses.ts | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts index 120332219d..e66ee062b5 100644 --- a/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts +++ b/packages/profile-sync-controller/src/controllers/user-storage/__fixtures__/mockResponses.ts @@ -34,9 +34,9 @@ export const getMockUserStorageEndpoint = ( }; /** - * Temp - * @param data - foo - * @returns bar + * Creates a mock GET user-storage response + * @param data - data to encrypt + * @returns a realistic GET Response Body */ export async function createMockGetStorageResponse( data?: string, @@ -48,9 +48,9 @@ export async function createMockGetStorageResponse( } /** - * Temp - * @param dataArr - foo - * @returns bar + * Creates a mock GET ALL user-storage response + * @param dataArr - array of data to encrypt + * @returns a realistic GET ALL Response Body */ export async function createMockAllFeatureEntriesResponse( dataArr: string[] = [MOCK_STORAGE_DATA], @@ -67,9 +67,9 @@ export async function createMockAllFeatureEntriesResponse( } /** - * Temp - * @param path - foo - * @returns bar + * Creates a mock user-storage api GET request + * @param path - path of the GET Url + * @returns mock GET API request. Can be used by e2e or unit mock servers */ export async function getMockUserStorageGetResponse( path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings', @@ -82,10 +82,10 @@ export async function getMockUserStorageGetResponse( } /** - * Temp - * @param path - foo - * @param dataArr - bar - * @returns baz + * Creates a mock user-storage api GET ALL request + * @param path - path of the GET url + * @param dataArr - data to encrypt + * @returns mock GET ALL API request. Can be used by e2e or unit mock servers */ export async function getMockUserStorageAllFeatureEntriesResponse( path: UserStoragePathWithFeatureOnly = 'notifications',