-
Notifications
You must be signed in to change notification settings - Fork 105
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
Showing
5 changed files
with
1,513 additions
and
44 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 |
---|---|---|
@@ -1,44 +1,46 @@ | ||
import { UIAttachment, UIMessageId } from "../../messages/types"; | ||
import { PNMessage } from "../store/types/types"; | ||
import { ThirdPartyMessageWithContent } from "../../../../definitions/backend/ThirdPartyMessageWithContent"; | ||
import { message_1 } from "../../messages/__mocks__/message"; | ||
import { ATTACHMENT_CATEGORY } from "../../messages/types/attachmentCategory"; | ||
import { NotificationRecipient } from "../../../../definitions/pn/NotificationRecipient"; | ||
|
||
export const messageId = "00000000000000000000000004" as UIMessageId; | ||
|
||
export const pnMessage: PNMessage = { | ||
export const thirdPartyMessage: ThirdPartyMessageWithContent = { | ||
...message_1, | ||
created_at: new Date("2020-01-01T00:00:00.000Z"), | ||
iun: "731143-7-0317-8200-0", | ||
subject: "This is the message subject", | ||
senderDenomination: "Sender denomination", | ||
abstract: "Message abstract", | ||
notificationStatusHistory: [], | ||
recipients: [ | ||
{ | ||
recipientType: "-", | ||
taxId: "AAABBB00A00A000A", | ||
denomination: "AaAaAa BbBbBb", | ||
payment: { | ||
noticeCode: "026773337463073118", | ||
creditorTaxId: "00000000009" | ||
} | ||
} | ||
] as Array<NotificationRecipient>, | ||
attachments: [ | ||
{ | ||
messageId, | ||
id: "1", | ||
displayName: "A First Attachment", | ||
contentType: "application/pdf", | ||
category: ATTACHMENT_CATEGORY.DOCUMENT, | ||
resourceUrl: { href: "/resource/attachment1.pdf" } | ||
}, | ||
{ | ||
messageId, | ||
id: "2", | ||
displayName: "A Second Attachment", | ||
contentType: "application/pdf", | ||
category: ATTACHMENT_CATEGORY.DOCUMENT, | ||
resourceUrl: { href: "/resource/attachment2.pdf" } | ||
third_party_message: { | ||
details: { | ||
abstract: "######## abstract ########", | ||
attachments: [ | ||
{ | ||
messageId: message_1.id, | ||
id: "1", | ||
displayName: "A First Attachment", | ||
contentType: "application/pdf", | ||
category: ATTACHMENT_CATEGORY.DOCUMENT, | ||
resourceUrl: { href: "/resource/attachment1.pdf" } | ||
}, | ||
{ | ||
messageId: message_1.id, | ||
id: "2", | ||
displayName: "A Second Attachment", | ||
contentType: "application/pdf", | ||
category: ATTACHMENT_CATEGORY.DOCUMENT, | ||
resourceUrl: { href: "/resource/attachment2.pdf" } | ||
} | ||
], | ||
iun: "731143-7-0317-8200-0", | ||
subject: "######## subject ########", | ||
recipients: [ | ||
{ | ||
recipientType: "-", | ||
taxId: "AAABBB00A00A000A", | ||
denomination: "AaAaAa BbBbBb", | ||
payment: { | ||
noticeCode: "026773337463073118", | ||
creditorTaxId: "00000000009" | ||
} | ||
} | ||
], | ||
notificationStatusHistory: [], | ||
senderDenomination: "Sender denomination" | ||
} | ||
] as Array<UIAttachment> | ||
} | ||
}; |
18 changes: 15 additions & 3 deletions
18
ts/features/pn/components/__test__/MessageDetails.test.tsx
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
83 changes: 83 additions & 0 deletions
83
ts/features/pn/screens/__test__/MessageDetailsScreen.test.tsx
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import configureMockStore from "redux-mock-store"; | ||
import { Action, Store } from "redux"; | ||
import PN_ROUTES from "../../navigation/routes"; | ||
import { GlobalState } from "../../../../store/reducers/types"; | ||
import { appReducer } from "../../../../store/reducers"; | ||
import { MessageDetailsScreen } from "../MessageDetailsScreen"; | ||
import { renderScreenWithNavigationStoreContext } from "../../../../utils/testWrapper"; | ||
import { reproduceSequence } from "../../../../utils/tests"; | ||
import { | ||
loadMessageById, | ||
loadMessageDetails, | ||
loadThirdPartyMessage | ||
} from "../../../messages/store/actions"; | ||
import { | ||
toUIMessage, | ||
toUIMessageDetails | ||
} from "../../../messages/store/reducers/transformers"; | ||
import { message_1 } from "../../../messages/__mocks__/message"; | ||
import { loadServiceDetail } from "../../../../store/actions/services"; | ||
import { service_1 } from "../../../messages/__mocks__/messages"; | ||
import { UIMessageId } from "../../../messages/types"; | ||
import { applicationChangeState } from "../../../../store/actions/application"; | ||
import { thirdPartyMessage } from "../../__mocks__/message"; | ||
|
||
describe("MessageDetailsScreen", () => { | ||
it("should match the snapshot when there is an error", () => { | ||
const sequenceOfActions: ReadonlyArray<Action> = [ | ||
applicationChangeState("active") | ||
]; | ||
|
||
const state: GlobalState = reproduceSequence( | ||
{} as GlobalState, | ||
appReducer, | ||
sequenceOfActions | ||
); | ||
const mockStore = configureMockStore<GlobalState>(); | ||
const store: Store<GlobalState> = mockStore(state); | ||
|
||
const { component } = renderComponent(store); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
it("should match the snapshot when everything went fine", () => { | ||
const sequenceOfActions: ReadonlyArray<Action> = [ | ||
applicationChangeState("active"), | ||
loadMessageById.success(toUIMessage(message_1)), | ||
loadServiceDetail.success(service_1), | ||
loadMessageDetails.success(toUIMessageDetails(message_1)), | ||
loadThirdPartyMessage.success({ | ||
id: message_1.id as UIMessageId, | ||
content: thirdPartyMessage | ||
}) | ||
]; | ||
|
||
const state: GlobalState = reproduceSequence( | ||
{} as GlobalState, | ||
appReducer, | ||
sequenceOfActions | ||
); | ||
const mockStore = configureMockStore<GlobalState>(); | ||
const store: Store<GlobalState> = mockStore(state); | ||
|
||
const { component } = renderComponent(store); | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
const renderComponent = (store: Store<GlobalState>) => { | ||
const { id, sender_service_id } = message_1; | ||
|
||
return { | ||
component: renderScreenWithNavigationStoreContext<GlobalState>( | ||
MessageDetailsScreen, | ||
PN_ROUTES.MESSAGE_DETAILS, | ||
{ | ||
firstTimeOpening: false, | ||
messageId: id, | ||
serviceId: sender_service_id | ||
}, | ||
store | ||
) | ||
}; | ||
}; |
Oops, something went wrong.