-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52dc953
commit 1cd864a
Showing
3 changed files
with
29 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,11 +172,21 @@ describe('API', () => { | |
}); | ||
|
||
test.each([successDictResponse, successListResponse])('Successful Fetch by email', async (successResponse) => { | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${testEmail}`).reply(200, successResponse); | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${encodeURIComponent(testEmail)}`).reply(200, successResponse); | ||
const response = await api.getUser(testEmail); | ||
expect(response).toEqual(Array.isArray(successResponse) ? successResponse[0] : successResponse); | ||
}); | ||
|
||
test.each([successDictResponse, successListResponse])('Successful Fetch by email with +', async (responseType) => { | ||
const testEmailWithPlus = '[email protected]'; | ||
const successResponse = { | ||
...Array.isArray(responseType) ? responseType[0] : responseType, testEmail: testEmailWithPlus, | ||
}; | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${encodeURIComponent(testEmailWithPlus)}`).reply(200, successResponse); | ||
const response = await api.getUser(testEmailWithPlus); | ||
expect(response).toEqual(Array.isArray(successResponse) ? successResponse[0] : successResponse); | ||
}); | ||
|
||
test.each([successDictResponse, successListResponse])('Successful Fetch by username', async (successResponse) => { | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}/${testUsername}`).reply(200, successResponse); | ||
const response = await api.getUser(testUsername); | ||
|
@@ -223,7 +233,7 @@ describe('API', () => { | |
type: 'error', | ||
topic: 'general', | ||
}; | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${testEmail}`).reply(() => throwError(404, '')); | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${encodeURIComponent(testEmail)}`).reply(() => throwError(404, '')); | ||
try { | ||
await api.getUser(testEmail); | ||
} catch (error) { | ||
|
@@ -239,7 +249,7 @@ describe('API', () => { | |
type: 'danger', | ||
topic: 'general', | ||
}; | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${testEmail}`).reply(() => throwError(500, '')); | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${encodeURIComponent(testEmail)}`).reply(() => throwError(500, '')); | ||
try { | ||
await api.getUser(testEmail); | ||
} catch (error) { | ||
|
@@ -263,7 +273,7 @@ describe('API', () => { | |
type: 'error', | ||
topic: 'general', | ||
}; | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${testEmail}`).reply(() => throwError(404, '')); | ||
mockAdapter.onGet(`${userAccountApiBaseUrl}?email=${encodeURIComponent(testEmail)}`).reply(() => throwError(404, '')); | ||
try { | ||
await api.getAllUserData(testEmail); | ||
} catch (error) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters