Skip to content

Commit 25e7f52

Browse files
committed
chore: solve some chore problems, make the code prettier
1 parent 8f606e3 commit 25e7f52

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

src/contactInfo/domain/useCases/SubmitContactInfo.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ export class SubmitContactInfo implements UseCase<Contact[]> {
99
constructor(contactRepository: IContactRepository) {
1010
this.contactRepository = contactRepository
1111
}
12+
1213
/**
1314
* Submits contact information and returns a DTO containing the submitted data.
1415
*
1516
* @param {ContactDTO} contactDTO - The contact information to be submitted.
1617
* @returns {Promise<Contact>} A promise resolving to a ContactDTO.
1718
*/
19+
1820
async execute(contactDTO: ContactDTO): Promise<Contact[]> {
1921
try {
2022
return await this.contactRepository.submitContactInfo(contactDTO)

test/functional/contact/SubmitContactInfo.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ describe('submitContactInfo', () => {
1212
})
1313

1414
test('should return success result on repository success', async () => {
15-
const subject = 'Data Question'
16-
const fromEmail = '[email protected]'
17-
1815
const contactDTO: ContactDTO = {
1916
targetId: 1,
20-
subject: subject,
17+
subject: 'Data Question',
2118
body: 'Please help me understand your data. Thank you!',
22-
fromEmail: fromEmail
19+
fromEmail: '[email protected]'
2320
}
2421

2522
let contactInfo
@@ -29,7 +26,7 @@ describe('submitContactInfo', () => {
2926
throw new Error('Contact info should be submitted')
3027
} finally {
3128
expect(contactInfo).toBeDefined()
32-
expect(contactInfo[0].fromEmail).toEqual(fromEmail)
29+
expect(contactInfo[0].fromEmail).toEqual('[email protected]')
3330
expect(contactInfo[0].subject).toEqual(expect.any(String))
3431
expect(contactInfo[0].body).toEqual(expect.any(String))
3532
expect(contactInfo[0].toEmail).toEqual(expect.any(String))

test/integration/contact/ContactRepository.test.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ describe('submitContactInfo', () => {
2222
const sut: ContactRepository = new ContactRepository()
2323

2424
test('should return ContactDTO when contact info is successfully submitted', async () => {
25-
try {
26-
const contactInfo = await sut.submitContactInfo(testContactDTO)
27-
expect(contactInfo).toBeDefined()
28-
expect(contactInfo[0].fromEmail).toEqual(testContactDTO.fromEmail)
29-
expect(contactInfo[0].subject).toEqual(expect.any(String))
30-
expect(contactInfo[0].body).toEqual(expect.any(String))
31-
expect(contactInfo[0].toEmail).toEqual(expect.any(String))
32-
} catch (error) {
33-
console.error('Error during submission:', error.message, error.response?.data)
34-
throw error
35-
}
25+
const contactInfo = await sut.submitContactInfo(testContactDTO)
26+
27+
expect(contactInfo).toBeDefined()
28+
expect(contactInfo[0].fromEmail).toEqual(testContactDTO.fromEmail)
29+
expect(contactInfo[0].subject).toEqual(expect.any(String))
30+
expect(contactInfo[0].body).toEqual(expect.any(String))
31+
expect(contactInfo[0].toEmail).toEqual(expect.any(String))
3632
})
3733

3834
test('should return error if the target id is unexisted', async () => {

test/unit/contact/SubmitContactInfo.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { WriteError, Contact, ContactDTO } from '../../../src'
22
import { SubmitContactInfo } from '../../../src/contactInfo/domain/useCases/SubmitContactInfo'
33
import { IContactRepository } from '../../../src/contactInfo/domain/repositories/IContactRepository'
44

5-
describe('execute', () => {
5+
describe('execute submit information to contacts', () => {
66
test('should return a ContactDTO when repository call is successful', async () => {
77
const fromEmail = '[email protected]'
88

0 commit comments

Comments
 (0)