-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encourage users to choose digital reminders (#1821)
* update content * move logic to route and add tests * code smells * code smell change email value setup * undo changes package.json * fix lint * refactor route and fix spelling issue * code smell
- Loading branch information
1 parent
6db6c87
commit 8358515
Showing
4 changed files
with
182 additions
and
50 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 |
---|---|---|
|
@@ -285,25 +285,31 @@ | |
"identify_title": "Renew your rod fishing licence?", | ||
"important_info_contact_error_choose": "Choose how we should contact the licence holder", | ||
"important_info_contact_error_email": "Enter an email address in the correct format", | ||
"important_info_contact_error_mobile": "Enter a UK mobile phone number", | ||
"important_info_contact_error_mobile": "Enter a UK mobile number", | ||
"important_info_contact_input_email_hint": "For example [email protected]", | ||
"important_info_contact_input_email": "Email address", | ||
"important_info_contact_input_mobile_hint": "For example 07700 900 900", | ||
"important_info_contact_input_mobile_note": "Mobile phone number", | ||
"important_info_contact_input_mobile": "UK mobile phone number", | ||
"important_info_contact_input_mobile_note": "UK mobile number", | ||
"important_info_contact_input_mobile": "UK mobile number", | ||
"important_info_contact_item_email": "Email", | ||
"important_info_contact_item_email_value": "Email ", | ||
"important_info_contact_item_txt": "Text message", | ||
"important_info_contact_item_txt_value": "Text message to ", | ||
"important_info_contact_licence_needed": "The rod licence holder will need to confirm the licence number if asked by an enforcement officer.", | ||
"important_info_contact_none_msg": "We will show you the licence number on confirmation.", | ||
"important_info_contact_note_tip": "Make a note of the licence number", | ||
"important_info_contact_post_hint_you": "By choosing post, you will not get a personalised link to renew your licence online before it expires.", | ||
"important_info_contact_post_hint_other": "By choosing post, the licence holder will not get a personalised link to renew their licence online before it expires.", | ||
"important_info_contact_post_confirm_8d": "We don’t provide physical cards for 1 or 8 day licences.", | ||
"important_info_contact_post_confirm_jr": "We don’t provide physical cards for junior licences.", | ||
"important_info_contact_post_confirm": "This is where we will send renewal reminders when the licence is ending.", | ||
"important_info_contact_post_confirm2": "We will also send important information like byelaw updates.", | ||
"important_info_contact_post_salmon_you": "We will send a renewal reminder before your licence expires and a reminder to report a catch return. We will also send other important updates, like rod fishing byelaw changes.", | ||
"important_info_contact_post_not_salmon_you": "We will send a renewal reminder before your licence expires. We will also send other important updates, like rod fishing byelaw changes.", | ||
"important_info_contact_post_salmon_other": "We will send a renewal reminder before the licence expires and a reminder to report a catch return. We will also send other important updates, like rod fishing byelaw changes.", | ||
"important_info_contact_post_not_salmon_other": "We will send a renewal reminder before the licence expires. We will also send other important updates, like rod fishing byelaw changes.", | ||
"important_info_contact_post_msg": "If you want to fish before you receive the card you should make a note of the licence number after payment.", | ||
"important_info_contact_post": "Post", | ||
"important_info_contact_title_other": "How should we contact the licence holder about reminders and important changes?", | ||
"important_info_contact_title_you": "How should we contact you with reminders and important changes?", | ||
"important_info_contact_title_other": "How should we contact the licence holder about updates affecting their licence?", | ||
"important_info_contact_title_you": "How should we contact you about updates affecting your licence?", | ||
"licence_confirm_method_error_choose": "Choose how we should send the licence", | ||
"licence_confirm_method_how_body_item": "I will make a note of the licence number", | ||
"licence_confirm_method_how_body_text": "This is where we will send confirmation of the fishing licence", | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ import { getData, validator } from '../route' | |
import pageRoute from '../../../../routes/page-route.js' | ||
import { nextPage } from '../../../../routes/next-page.js' | ||
import { isPhysical } from '../../../../processors/licence-type-display.js' | ||
import { hasJunior } from '../../../../processors/concession-helper.js' | ||
|
||
jest.mock('../../../../routes/next-page.js', () => ({ | ||
nextPage: jest.fn() | ||
|
@@ -15,46 +16,115 @@ jest.mock('../../../../uri.js', () => ({ | |
} | ||
})) | ||
jest.mock('../../../../processors/licence-type-display.js') | ||
jest.mock('../../../../processors/concession-helper.js') | ||
|
||
describe('name > route', () => { | ||
const getMockRequest = (isLicenceForYou = true) => ({ | ||
const getMockRequest = ({ isLicenceForYou, licenceType, email, mobilePhone }) => ({ | ||
cache: () => ({ | ||
helpers: { | ||
transaction: { | ||
getCurrentPermission: () => ({ | ||
licensee: { | ||
birthDate: 'birthDate' | ||
birthDate: 'birthDate', | ||
email, | ||
mobilePhone | ||
}, | ||
licenceLength: 'licenceLength', | ||
licenceStartDate: 'licenceStartDate', | ||
isLicenceForYou | ||
isLicenceForYou, | ||
licenceType | ||
}) | ||
} | ||
} | ||
}) | ||
}), | ||
i18n: { | ||
getCatalog: () => getMessages() | ||
} | ||
}) | ||
|
||
const getMessages = () => ({ | ||
important_info_contact_title_you: 'You title', | ||
important_info_contact_title_other: 'Other title', | ||
important_info_contact_item_email: 'Email', | ||
important_info_contact_item_email_value: 'Email ', | ||
important_info_contact_item_txt_value: 'Text to ', | ||
important_info_contact_item_txt: 'Text', | ||
important_info_contact_post_hint_you: 'Post hint you', | ||
important_info_contact_post_hint_other: 'Post hint other', | ||
important_info_contact_post_salmon_you: 'Salmon you', | ||
important_info_contact_post_not_salmon_you: 'Not salmon you', | ||
important_info_contact_post_salmon_other: 'Salmon other', | ||
important_info_contact_post_not_salmon_other: 'Not salmon other' | ||
}) | ||
|
||
describe('getData', () => { | ||
it('should return isLicenceForYou as true, if isLicenceForYou is true on the transaction cache', async () => { | ||
const result = await getData(getMockRequest(true)) | ||
expect(result.isLicenceForYou).toBeTruthy() | ||
it.each([ | ||
[true, 'You title'], | ||
[false, 'Other title'] | ||
])('title return method is %s if isLicenceForYou is same', async (isLicenceForYou, expected) => { | ||
const result = await getData(getMockRequest({ isLicenceForYou })) | ||
expect(result.title).toBe(expected) | ||
}) | ||
|
||
it('should return isLicenceForYou as false, if isLicenceForYou is false on the transaction cache', async () => { | ||
const result = await getData(getMockRequest(false)) | ||
expect(result.isLicenceForYou).toBeFalsy() | ||
it.each([ | ||
['[email protected]', 'Email [email protected]'], | ||
[null, 'Email'] | ||
])('emailText has correct value depending on if permission has an email', async (email, expected) => { | ||
const result = await getData(getMockRequest({ email })) | ||
expect(result.emailText).toBe(expected) | ||
}) | ||
|
||
it.each([ | ||
['07123456789', 'Text to 07123456789'], | ||
[null, 'Text'] | ||
])('mobileText has correct value depending on if permission has a phone number', async (mobilePhone, expected) => { | ||
const result = await getData(getMockRequest({ mobilePhone })) | ||
expect(result.mobileText).toBe(expected) | ||
}) | ||
|
||
it.each([ | ||
[true, 'Post hint you'], | ||
[false, 'Post hint other'] | ||
])('postHint wording depending on whether isLicenceForYou is %s', async (isLicenceForYou, expected) => { | ||
const result = await getData(getMockRequest({ isLicenceForYou })) | ||
expect(result.postHint).toBe(expected) | ||
}) | ||
|
||
it.each([ | ||
[true, 'Salmon and sea trout', 'Salmon you'], | ||
[true, 'Trout and coarse', 'Not salmon you'], | ||
[false, 'Salmon and sea trout', 'Salmon other'], | ||
[false, 'Trout and coarse', 'Not salmon other'] | ||
])( | ||
'content has correct value depending on isLicenceForYou is %s and licenceType is %s', | ||
async (isLicenceForYou, licenceType, expected) => { | ||
const result = await getData(getMockRequest({ isLicenceForYou, licenceType })) | ||
expect(result.content).toBe(expected) | ||
} | ||
) | ||
|
||
it.each([ | ||
[true, true], | ||
[false, false] | ||
])('result.isPhysical matches return method of isPhysical', async (physical, expected) => { | ||
isPhysical.mockReturnValueOnce(physical) | ||
const result = await getData(getMockRequest({})) | ||
expect(result.isPhysical).toBe(expected) | ||
}) | ||
|
||
it('return isPhysical as true, if isPhysical is true for the permission', async () => { | ||
isPhysical.mockReturnValueOnce(true) | ||
const result = await getData(getMockRequest()) | ||
expect(result.isPhysical).toBeTruthy() | ||
it.each([ | ||
[true, true], | ||
[false, false] | ||
])('isJunior matches return method of hasJunior', async (physical, expected) => { | ||
hasJunior.mockReturnValueOnce(physical) | ||
const result = await getData(getMockRequest({})) | ||
expect(result.isJunior).toBe(expected) | ||
}) | ||
|
||
it('return isPhysical as false, if isPhysical is false for the permission', async () => { | ||
isPhysical.mockReturnValueOnce(false) | ||
const result = await getData(getMockRequest()) | ||
expect(result.isPhysical).toBeFalsy() | ||
it('howContacted returns the value of HOW_CONTACTED', async () => { | ||
const expectedValue = { email: 'Email', text: 'Text', letter: 'Letter', none: 'Prefer not to be contacted' } | ||
const result = await getData(getMockRequest({})) | ||
expect(result.howContacted).toEqual(expectedValue) | ||
}) | ||
}) | ||
|
||
|
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