-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHES Notifications & Logger Adjustment (#2730)
Co-authored-by: LawrenceLau2020 <[email protected]>
- Loading branch information
1 parent
eaf7cdf
commit 6c9077c
Showing
3 changed files
with
48 additions
and
4 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
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 |
---|---|---|
|
@@ -23,6 +23,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => `{ "messages": [{}], "txId": "${randomUUID()}" }`, | ||
})); | ||
const response = await chesServices.sendEmailAsync(email, keycloak); | ||
|
@@ -35,10 +36,37 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: false, | ||
text: () => `{ "messages": [{}], "txId": "${randomUUID()}" }`, | ||
})); | ||
expect(async () => await chesServices.sendEmailAsync(email, keycloak)).rejects.toThrow(); | ||
}); | ||
it('should return null if the CHES response is not OK', async () => { | ||
const email = produceEmail({ cc: ['[email protected]'], bcc: ['[email protected]'] }); | ||
const keycloak = producePimsRequestUser(); | ||
_fetch.mockImplementationOnce(() => ({ | ||
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: false, | ||
text: () => `{ "messages": [{}], "txId": "${randomUUID()}" }`, | ||
})); | ||
const result = await chesServices.sendEmailAsync(email, keycloak); | ||
expect(result).toBeNull(); | ||
}); | ||
it('should return null if the CHES response has no text length', async () => { | ||
const email = produceEmail({ cc: ['[email protected]'], bcc: ['[email protected]'] }); | ||
const keycloak = producePimsRequestUser(); | ||
_fetch.mockImplementationOnce(() => ({ | ||
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ``, | ||
})); | ||
const result = await chesServices.sendEmailAsync(email, keycloak); | ||
expect(result).toBeNull(); | ||
}); | ||
it('should send email with extra config', async () => { | ||
const email: IEmail = produceEmail({}); | ||
const keycloak = producePimsRequestUser(); | ||
|
@@ -55,6 +83,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => `{ "messages": [{}], "txId": "${randomUUID()}" }`, | ||
})); | ||
const response = await chesServices.sendEmailAsync(email, keycloak); | ||
|
@@ -67,8 +96,8 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ` | ||
{ | ||
"createdTS": 1560000000, | ||
|
@@ -102,6 +131,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ` | ||
[ | ||
{ | ||
|
@@ -143,6 +173,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ` | ||
{ | ||
|
@@ -177,6 +208,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ` | ||
{ | ||
|
@@ -202,6 +234,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ` | ||
{ | ||
|
@@ -238,6 +271,7 @@ describe('UNIT - Ches Services', () => { | |
text: () => '{"access_token":"eyAiYSI6IDEgfQ==.ewoiZXhwIjoxCn0="}', | ||
})); | ||
_fetch.mockImplementationOnce(() => ({ | ||
ok: true, | ||
text: () => ` | ||
[ | ||
{ | ||
|