-
Notifications
You must be signed in to change notification settings - Fork 8
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
50590eb
commit 8728186
Showing
2 changed files
with
26 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ describe('submitContactInfo', () => { | |
const fromEmail = '[email protected]' | ||
|
||
const contactDTO: ContactDTO = { | ||
targetId: 6, | ||
targetId: 1, | ||
subject: subject, | ||
body: 'Please help me understand your data. Thank you!', | ||
fromEmail: fromEmail | ||
|
@@ -31,9 +31,9 @@ describe('submitContactInfo', () => { | |
} finally { | ||
expect(contactInfo).toBeDefined() | ||
expect(contactInfo[0].fromEmail).toEqual(fromEmail) | ||
expect(contactInfo[0].subject).toBeDefined() | ||
expect(contactInfo[0].body).toBeDefined() | ||
expect(contactInfo[0].toEmail).toBeDefined() | ||
expect(contactInfo[0].subject).toEqual(expect.any(String)) | ||
expect(contactInfo[0].body).toEqual(expect.any(String)) | ||
expect(contactInfo[0].toEmail).toEqual(expect.any(String)) | ||
} | ||
}) | ||
|
||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ describe('submitContactInfo', () => { | |
}) | ||
|
||
const testContactDTO: ContactDTO = { | ||
targetId: 6, | ||
targetId: 1, | ||
subject: 'Data Question', | ||
body: 'Please help me understand your data. Thank you!', | ||
fromEmail: '[email protected]' | ||
|
@@ -22,23 +22,27 @@ describe('submitContactInfo', () => { | |
const sut: ContactRepository = new ContactRepository() | ||
|
||
test('should return ContactDTO when contact info is successfully submitted', async () => { | ||
const contactInfo = await sut.submitContactInfo(testContactDTO) | ||
|
||
expect(contactInfo).toBeDefined() | ||
expect(contactInfo[0].fromEmail).toEqual(testContactDTO.fromEmail) | ||
expect(contactInfo[0].subject).toBeDefined() | ||
expect(contactInfo[0].body).toBeDefined() | ||
expect(contactInfo[0].toEmail).toBeDefined() | ||
}) | ||
|
||
test('should return error if the target id is unexisted', async () => { | ||
const invalidContactDTO: ContactDTO = { | ||
targetId: 0, | ||
subject: '', | ||
body: '', | ||
fromEmail: '' | ||
try { | ||
const contactInfo = await sut.submitContactInfo(testContactDTO) | ||
expect(contactInfo).toBeDefined() | ||
expect(contactInfo[0].fromEmail).toEqual(testContactDTO.fromEmail) | ||
expect(contactInfo[0].subject).toEqual(expect.any(String)) | ||
expect(contactInfo[0].body).toEqual(expect.any(String)) | ||
expect(contactInfo[0].toEmail).toEqual(expect.any(String)) | ||
} catch (error) { | ||
console.error('Error during submission:', error.message, error.response?.data) | ||
throw error | ||
} | ||
const expectedError = new WriteError(`[400] Feedback target object not found`) | ||
await expect(sut.submitContactInfo(invalidContactDTO)).rejects.toThrow(expectedError) | ||
|
||
test('should return error if the target id is unexisted', async () => { | ||
const invalidContactDTO: ContactDTO = { | ||
targetId: 0, | ||
subject: '', | ||
body: '', | ||
fromEmail: '' | ||
} | ||
const expectedError = new WriteError(`[400] Feedback target object not found`) | ||
await expect(sut.submitContactInfo(invalidContactDTO)).rejects.toThrow(expectedError) | ||
}) | ||
}) | ||
}) |