generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMessageTemplates.test.tsx
More file actions
131 lines (119 loc) · 4.24 KB
/
MessageTemplates.test.tsx
File metadata and controls
131 lines (119 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import { render, screen } from '@testing-library/react';
import { MessageTemplates } from '@molecules/MessageTemplates/MessageTemplates';
import content from '@content/content';
import { TemplateDto } from 'nhs-notify-backend-client';
const messageTemplatesContent = content.pages.messageTemplates;
const messageTemplatesProps: {
templateList: TemplateDto[];
} = {
templateList: [
{
id: '1',
templateType: 'NHS_APP',
templateStatus: 'NOT_YET_SUBMITTED',
name: 'Template 1',
message: 'Message',
createdAt: '2021-01-01T00:00:00.000Z',
updatedAt: '2021-01-01T00:00:00.000Z',
},
{
id: '2',
templateType: 'NHS_APP',
templateStatus: 'SUBMITTED',
name: 'Template 2',
message: 'Message',
createdAt: '2021-01-01T00:00:00.000Z',
updatedAt: '2021-03-01T00:00:00.000Z',
},
{
id: '3',
templateType: 'LETTER',
templateStatus: 'SUBMITTED',
name: 'Template 3',
createdAt: '2021-02-01T00:00:00.000Z',
letterType: 'x0',
language: 'en',
updatedAt: '2021-02-01T00:00:00.000Z',
files: {
pdfTemplate: {
fileName: 'template.pdf',
currentVersion: '8BAC',
virusScanStatus: 'PASSED',
},
},
},
{
id: '4',
templateType: 'LETTER',
templateStatus: 'NOT_YET_SUBMITTED',
name: 'Template 4',
createdAt: '2021-02-01T00:00:00.000Z',
letterType: 'x0',
language: 'fr',
updatedAt: '2021-02-01T00:00:00.000Z',
files: {
pdfTemplate: {
fileName: 'template.pdf',
currentVersion: '8BAC',
virusScanStatus: 'PASSED',
},
},
},
],
};
describe('MessageTemplates component', () => {
it('matches snapshot with not submitted status', () => {
const container = render(<MessageTemplates {...messageTemplatesProps} />);
expect(container.asFragment()).toMatchSnapshot();
});
it('matches snapshot with submitted status', () => {
messageTemplatesProps.templateList[0].templateStatus = 'SUBMITTED';
const container = render(<MessageTemplates {...messageTemplatesProps} />);
expect(container.asFragment()).toMatchSnapshot();
});
it('matches snapshot with pending proof request status', () => {
messageTemplatesProps.templateList[0].templateStatus =
'PENDING_PROOF_REQUEST';
const container = render(<MessageTemplates {...messageTemplatesProps} />);
expect(container.asFragment()).toMatchSnapshot();
});
it('matches snapshot with waiting for proof status', () => {
messageTemplatesProps.templateList[0].templateStatus = 'WAITING_FOR_PROOF';
const container = render(<MessageTemplates {...messageTemplatesProps} />);
expect(container.asFragment()).toMatchSnapshot();
});
it('renders component correctly', () => {
render(<MessageTemplates {...messageTemplatesProps} />);
expect(screen.getByTestId('manage-template-table')).toBeInTheDocument();
expect(
screen.getByTestId('manage-template-table-header-template-name')
).toBeInTheDocument();
expect(
screen.getByTestId('manage-template-table-header-template-name')
).toHaveTextContent(messageTemplatesContent.tableHeadings.name);
expect(
screen.getByTestId('manage-template-table-header-template-type')
).toBeInTheDocument();
expect(
screen.getByTestId('manage-template-table-header-template-type')
).toHaveTextContent(messageTemplatesContent.tableHeadings.type);
expect(
screen.getByTestId('manage-template-table-header-template-status')
).toBeInTheDocument();
expect(
screen.getByTestId('manage-template-table-header-template-status')
).toHaveTextContent(messageTemplatesContent.tableHeadings.status);
expect(
screen.getByTestId('manage-template-table-header-template-date-created')
).toBeInTheDocument();
expect(
screen.getByTestId('manage-template-table-header-template-date-created')
).toHaveTextContent(messageTemplatesContent.tableHeadings.lastEdited);
expect(
screen.getByTestId('manage-template-table-header-action')
).toBeInTheDocument();
expect(
screen.getByTestId('manage-template-table-header-action')
).toHaveTextContent(messageTemplatesContent.tableHeadings.action.text);
});
});