-
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
6cdfde3
commit 50590eb
Showing
3 changed files
with
15 additions
and
74 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 |
---|---|---|
|
@@ -14,9 +14,6 @@ describe('submitContactInfo', () => { | |
test('should return success result on repository success', async () => { | ||
const subject = 'Data Question' | ||
const fromEmail = '[email protected]' | ||
const collectionAlias = 'collection-1' | ||
const collectionEmail = '[email protected],[email protected]' | ||
const baseUrl = 'http://localhost:8080/dataverse/' | ||
|
||
const contactDTO: ContactDTO = { | ||
targetId: 6, | ||
|
@@ -25,51 +22,24 @@ describe('submitContactInfo', () => { | |
fromEmail: fromEmail | ||
} | ||
|
||
const bodyMessage = | ||
'You have just been sent the following message from ' + | ||
fromEmail + | ||
' via the Root hosted dataverse named "' + | ||
collectionAlias + | ||
'":\n' + | ||
'\n' + | ||
'---\n' + | ||
'\n' + | ||
'Please help me understand your data. Thank you!\n' + | ||
'\n' + | ||
'---\n' + | ||
'\n' + | ||
'Root Support\n' + | ||
'null\n' + | ||
'\n' + | ||
'Go to dataverse ' + | ||
baseUrl + | ||
collectionAlias + | ||
'\n' + | ||
'\n' + | ||
'You received this email because you have been listed as a contact for the dataverse. If you believe this was an error, please contact Root Support at null. To respond directly to the individual who sent the message, simply reply to this email.' | ||
|
||
const expectedResponse = [ | ||
{ | ||
fromEmail: fromEmail, | ||
toEmail: collectionEmail, | ||
subject: 'Root contact: ' + subject, | ||
body: bodyMessage | ||
} | ||
] | ||
|
||
let contactInfo | ||
try { | ||
contactInfo = await submitContactInfo.execute(contactDTO) | ||
console.log('contactInfo:', contactInfo) | ||
} catch (error) { | ||
throw new Error('Contact info should be submitted') | ||
} finally { | ||
expect(contactInfo).toEqual(expectedResponse) | ||
expect(contactInfo).toBeDefined() | ||
expect(contactInfo[0].fromEmail).toEqual(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 contactDTO: ContactDTO = { | ||
targetId: 0, // non-existent target id | ||
targetId: 0, | ||
subject: '', | ||
body: '', | ||
fromEmail: '[email protected]' | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { ContactRepository } from '../../../src/contactInfo/infra/repositories/ContactRepository' | ||
import { ApiConfig, Contact, ContactDTO, WriteError } from '../../../src' | ||
import { ApiConfig, ContactDTO, WriteError } from '../../../src' | ||
import { DataverseApiAuthMechanism } from '../../../src/core/infra/repositories/ApiConfig' | ||
import { TestConstants } from '../../testHelpers/TestConstants' | ||
|
||
|
@@ -22,42 +22,13 @@ describe('submitContactInfo', () => { | |
const sut: ContactRepository = new ContactRepository() | ||
|
||
test('should return ContactDTO when contact info is successfully submitted', async () => { | ||
const collectionAlias = 'collection-1' | ||
const collectionEmail = '[email protected],[email protected]' | ||
const baseUrl = 'http://localhost:8080/dataverse/' | ||
const bodyMessage = | ||
'You have just been sent the following message from ' + | ||
testContactDTO.fromEmail + | ||
' via the Root hosted dataverse named "' + | ||
collectionAlias + | ||
'":\n' + | ||
'\n' + | ||
'---\n' + | ||
'\n' + | ||
'Please help me understand your data. Thank you!\n' + | ||
'\n' + | ||
'---\n' + | ||
'\n' + | ||
'Root Support\n' + | ||
'null\n' + | ||
'\n' + | ||
'Go to dataverse ' + | ||
baseUrl + | ||
collectionAlias + | ||
'\n' + | ||
'\n' + | ||
'You received this email because you have been listed as a contact for the dataverse. If you believe this was an error, please contact Root Support at null. To respond directly to the individual who sent the message, simply reply to this email.' | ||
const contactInfo = await sut.submitContactInfo(testContactDTO) | ||
|
||
const expectedResponse: Contact[] = [ | ||
{ | ||
fromEmail: testContactDTO.fromEmail, | ||
toEmail: collectionEmail, | ||
subject: 'Root contact: ' + testContactDTO.subject, | ||
body: bodyMessage | ||
} | ||
] | ||
const actual = await sut.submitContactInfo(testContactDTO) | ||
expect(actual).toEqual(expectedResponse) | ||
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 () => { | ||
|