Skip to content

Commit eee372f

Browse files
committed
add tests
1 parent 8ec7eb2 commit eee372f

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/controllers/update/update.manage.trusts.review.individuals.controller.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ const individuals = [{
7272
surname: 'OLeary',
7373
id: 'tom-oleary-1',
7474
type: RoleWithinTrustType.SETTLOR,
75+
}, {
76+
forename: null,
77+
surname: 'Dummy',
78+
id: 'dermott-jones-1',
79+
type: RoleWithinTrustType.GRANTOR,
7580
}];
7681

7782
const createTrusts = (inReview = true) => {
@@ -125,6 +130,42 @@ describe('Update - Manage Trusts - Review individuals', () => {
125130
expect(resp.text).not.toContain(PAGE_TITLE_ERROR);
126131
});
127132

133+
test('filters out individual missing forename or surname', async () => {
134+
const trusts = createTrusts();
135+
const trustInReview = trusts[0];
136+
const appData = { update: { review_trusts: trusts } };
137+
138+
mockIsActiveFeature.mockReturnValueOnce(true);
139+
mockGetApplicationData.mockReturnValueOnce(appData);
140+
mockGetTrustInReview.mockReturnValueOnce(trustInReview);
141+
142+
const resp = await request(app).get(UPDATE_MANAGE_TRUSTS_REVIEW_INDIVIDUALS_URL);
143+
144+
expect(resp.status).toEqual(200);
145+
146+
expect(mockGetTrustInReview).toHaveBeenCalledWith(appData);
147+
expect(mockGetTrustInReview).toHaveBeenCalledTimes(1);
148+
149+
expect(resp.text).toContain("Review individuals");
150+
expect(resp.text).toContain(UPDATE_MANAGE_TRUSTS_REVIEW_THE_TRUST_URL);
151+
152+
expect(resp.text).toContain('Dermott Jones');
153+
expect(resp.text).toContain('Grantor');
154+
expect(resp.text).toContain('Change');
155+
expect(resp.text).toContain(`${UPDATE_MANAGE_TRUSTS_TELL_US_ABOUT_THE_INDIVIDUAL_URL}/dermott-jones-1`);
156+
157+
expect(resp.text).toContain('Tom OLeary');
158+
expect(resp.text).toContain('Settlor');
159+
expect(resp.text).toContain('Change');
160+
expect(resp.text).toContain(`${UPDATE_MANAGE_TRUSTS_TELL_US_ABOUT_THE_INDIVIDUAL_URL}/tom-oleary-1`);
161+
162+
expect(resp.text).not.toContain('Dummy');
163+
164+
expect(resp.text).toContain('Add an individual');
165+
expect(resp.text).toContain('No more to add');
166+
expect(resp.text).not.toContain(PAGE_TITLE_ERROR);
167+
});
168+
128169
test.each([
129170
['Uppercase', 'BENEFICIARY'],
130171
['Camelcase', 'Beneficiary'],

0 commit comments

Comments
 (0)