Skip to content

Commit

Permalink
fix: broken receiver tests due to answer field
Browse files Browse the repository at this point in the history
  • Loading branch information
LinHuiqing committed Sep 20, 2023
1 parent ac76b77 commit 4555583
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,13 @@ describe('receiver.service', () => {
const result = await resultPromise
expect(result._unsafeUnwrap()).toEqual({
responses: [
{
expect.objectContaining({
_id: mockResponse._id,
question: mockResponse.question,
answer: VALID_UTF8_FILENAME,
fieldType: mockResponse.fieldType,
filename: VALID_UTF8_FILENAME,
content: Buffer.concat([VALID_UTF8_FILE_CONTENT]),
},
}),
],
})
})
Expand Down Expand Up @@ -235,14 +234,13 @@ describe('receiver.service', () => {
const result = await resultPromise
expect(result._unsafeUnwrap()).toEqual({
responses: [
{
expect.objectContaining({
_id: mockResponse._id,
question: mockResponse.question,
answer: VALID_FILENAME_1,
fieldType: mockResponse.fieldType,
filename: VALID_FILENAME_1,
content: Buffer.concat([VALID_FILE_CONTENT_1]),
},
}),
],
})
})
Expand Down Expand Up @@ -282,14 +280,13 @@ describe('receiver.service', () => {
const result = await resultPromise
expect(result._unsafeUnwrap()).toEqual({
responses: [
{
expect.objectContaining({
_id: mockAttachment._id,
question: mockAttachment.question,
answer: VALID_FILENAME_1,
fieldType: mockAttachment.fieldType,
filename: VALID_FILENAME_1,
content: Buffer.concat([VALID_FILE_CONTENT_1]),
},
}),
{
_id: mockTextField._id,
question: mockTextField.question,
Expand Down Expand Up @@ -410,22 +407,20 @@ describe('receiver.service', () => {
const result = await resultPromise
expect(result._unsafeUnwrap()).toEqual({
responses: [
{
expect.objectContaining({
_id: mockResponse1._id,
question: mockResponse1.question,
answer: `1-${VALID_FILENAME_1}`,
fieldType: mockResponse1.fieldType,
filename: `1-${VALID_FILENAME_1}`,
content: Buffer.concat([VALID_FILE_CONTENT_1]),
},
{
}),
expect.objectContaining({
_id: mockResponse2._id,
question: mockResponse2.question,
answer: VALID_FILENAME_1,
fieldType: mockResponse2.fieldType,
filename: VALID_FILENAME_1,
content: Buffer.concat([VALID_FILE_CONTENT_1]),
},
}),
],
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,6 @@ describe('email-submission.util', () => {
).toEqual(secondAttachment.content)
})

it('should overwrite answer with filename when they are different', () => {
const attachment = validSingleFile
const response = getResponse(attachment.fieldId, MOCK_ANSWER)
addAttachmentToResponses([response], [attachment])
expect(response.answer).toBe(attachment.filename)
expect((response as unknown as IAttachmentResponse).filename).toBe(
attachment.filename,
)
expect((response as unknown as IAttachmentResponse).content).toEqual(
attachment.content,
)
})

it('should do nothing when responses are empty', () => {
const responses: FieldResponse[] = []
addAttachmentToResponses(responses, [validSingleFile])
Expand Down

0 comments on commit 4555583

Please sign in to comment.