-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
068c88f
commit 957febe
Showing
5 changed files
with
188 additions
and
112 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
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 |
---|---|---|
|
@@ -40,59 +40,95 @@ describe('View Licence Contact Details presenter', () => { | |
address: ['Crinkley Bottom', 'Cricket St Thomas', 'Somerset', 'TA20 1KL', 'United Kingdom'], | ||
role: 'Returns to', | ||
name: 'Mr N Edmonds' | ||
}, | ||
{ | ||
email: '[email protected]', | ||
role: 'Primary user' | ||
}, | ||
{ | ||
email: '[email protected]', | ||
role: 'Returns agent' | ||
} | ||
] | ||
}) | ||
}) | ||
|
||
describe('the "licenceContactDetails" property', () => { | ||
describe('the "licenceContactDetails.address" property', () => { | ||
it('returns the address of the property', () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
expect(result.licenceContactDetails[0].address).to.equal([ | ||
'ENVIRONMENT AGENCY', | ||
'HORIZON HOUSE', | ||
'DEANERY ROAD', | ||
'BRISTOL', | ||
'BS1 5AH', | ||
'United Kingdom' | ||
]) | ||
describe('when the licence contact is a "contact"', () => { | ||
describe('the "licenceContactDetails.address" property', () => { | ||
it('returns the address of the property', () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
expect(result.licenceContactDetails[0].address).to.equal([ | ||
'ENVIRONMENT AGENCY', | ||
'HORIZON HOUSE', | ||
'DEANERY ROAD', | ||
'BRISTOL', | ||
'BS1 5AH', | ||
'United Kingdom' | ||
]) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('the "licenceContactDetails.role" property', () => { | ||
describe('when one of the licence contact details has the role type of "Enforcement officer"', () => { | ||
it('returns licenceContactDetails without the contact with the role type of "Enforcement officer"', () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
describe('the "licenceContactDetails.role" property', () => { | ||
describe('when one of the licence contact details has the role type of "Enforcement officer"', () => { | ||
it('returns licenceContactDetails without the contact with the role type of "Enforcement officer"', () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
const hasEnforcementOfficer = result.licenceContactDetails.some((contact) => { | ||
return contact.role === 'Enforcement officer' | ||
}) | ||
const hasEnforcementOfficer = result.licenceContactDetails.some((contact) => { | ||
return contact.role === 'Enforcement officer' | ||
}) | ||
|
||
expect(hasEnforcementOfficer).to.be.false() | ||
expect(hasEnforcementOfficer).to.be.false() | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('the "licenceContacts.name" property', () => { | ||
describe('when the initials are null', () => { | ||
beforeEach(() => { | ||
licenceContactDetailsData.licenceDocumentHeader.metadata.contacts[3].initials = null | ||
describe('the "licenceContacts.name" property', () => { | ||
describe('when the initials are null', () => { | ||
beforeEach(() => { | ||
licenceContactDetailsData.licenceDocumentHeader.metadata.contacts[3].initials = null | ||
}) | ||
|
||
it("returns the licence contact's forename and name", () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
expect(result.licenceContactDetails[2].name).to.equal('Mr Noel Edmonds') | ||
}) | ||
}) | ||
|
||
it("returns the licence contact's forename and name", () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
describe('when the initials are not null', () => { | ||
it("returns the licence contact's forename and name", () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
expect(result.licenceContactDetails[2].name).to.equal('Mr Noel Edmonds') | ||
expect(result.licenceContactDetails[2].name).to.equal('Mr N Edmonds') | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when the initials are not null', () => { | ||
it("returns the licence contact's forename and name", () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
describe('when the licence contact is a "licenceEntityRole"', () => { | ||
describe('the "licenceContactDetails" property', () => { | ||
describe('and the role is "primary_user"', () => { | ||
it('returns the email and formatted role', () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
expect(result.licenceContactDetails[2].name).to.equal('Mr N Edmonds') | ||
expect(result.licenceContactDetails[3]).to.equal({ | ||
email: '[email protected]', | ||
role: 'Primary user' | ||
}) | ||
}) | ||
}) | ||
|
||
describe('and the role is "user_returns"', () => { | ||
it('returns the email and formatted role', () => { | ||
const result = ViewLicenceContactDetailsPresenter.go(licenceContactDetailsData) | ||
|
||
expect(result.licenceContactDetails[4]).to.equal({ | ||
email: '[email protected]', | ||
role: 'Returns agent' | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
@@ -175,7 +211,20 @@ function _testFetchLicenceContactDetailsData() { | |
], | ||
IsCurrent: false | ||
}, | ||
licenceEntityRoles: [] | ||
licenceEntityRoles: [ | ||
{ | ||
role: 'primary_user', | ||
licenceEntity: { | ||
name: '[email protected]' | ||
} | ||
}, | ||
{ | ||
role: 'user_returns', | ||
licenceEntity: { | ||
name: '[email protected]' | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ const { expect } = Code | |
|
||
// Test helpers | ||
const LicenceHelper = require('../../support/helpers/licence.helper.js') | ||
const LicenceDocumentHeaderHelper = require('../../support/helpers/licence-document-header.helper.js') | ||
const CRMContactDetailsSeeder = require('../../support/seeders/crm-contact-details.seeder.js') | ||
|
||
// Thing under test | ||
const FetchLicenceContactDetailsService = require('../../../app/services/licences/fetch-licence-contact-details.service.js') | ||
|
@@ -18,16 +18,18 @@ describe('Fetch Licence Contact Details service', () => { | |
let licence | ||
let licenceId | ||
let licenceRef | ||
let licenceDocumentHeader | ||
let licenceDocumentHeaderId | ||
|
||
describe('when the licence has a licence document header', () => { | ||
before(async () => { | ||
licence = await LicenceHelper.add() | ||
const { primaryUser: licenceDocumentHeader } = await CRMContactDetailsSeeder.seed(false) | ||
|
||
licence = await LicenceHelper.add({ | ||
licenceRef: licenceDocumentHeader.licenceRef | ||
}) | ||
|
||
licenceId = licence.id | ||
licenceRef = licence.licenceRef | ||
|
||
licenceDocumentHeader = await LicenceDocumentHeaderHelper.add({ licenceRef }) | ||
licenceDocumentHeaderId = licenceDocumentHeader.id | ||
}) | ||
|
||
|
@@ -39,42 +41,58 @@ describe('Fetch Licence Contact Details service', () => { | |
licenceRef, | ||
licenceDocumentHeader: { | ||
id: licenceDocumentHeaderId, | ||
licenceEntityRoles: [], | ||
licenceEntityRoles: [ | ||
{ | ||
role: 'primary_user', | ||
licenceEntity: { | ||
name: '[email protected]' | ||
} | ||
}, | ||
{ | ||
role: 'user_returns', | ||
licenceEntity: { | ||
name: '[email protected]' | ||
} | ||
} | ||
], | ||
metadata: { | ||
Name: 'GUPTA', | ||
Town: 'BRISTOL', | ||
County: 'AVON', | ||
Country: '', | ||
Expires: null, | ||
Forename: 'AMARA', | ||
Initials: 'A', | ||
Modified: '20080327', | ||
Postcode: 'BS1 5AH', | ||
Name: 'Primary User test', | ||
contacts: [ | ||
{ | ||
name: 'GUPTA', | ||
addressLine1: '4', | ||
addressLine2: 'Privet Drive', | ||
addressLine3: null, | ||
addressLine4: null, | ||
country: null, | ||
county: 'Surrey', | ||
forename: 'Harry', | ||
initials: 'J', | ||
name: 'Primary User test', | ||
postcode: 'WD25 7LR', | ||
role: 'Licence holder', | ||
town: 'BRISTOL', | ||
type: 'Person', | ||
county: 'AVON', | ||
salutation: null, | ||
town: 'Little Whinging', | ||
type: 'Person' | ||
}, | ||
{ | ||
addressLine1: '4', | ||
addressLine2: 'Privet Drive', | ||
addressLine3: null, | ||
addressLine4: null, | ||
country: null, | ||
forename: 'AMARA', | ||
initials: 'A', | ||
postcode: 'BS1 5AH', | ||
county: 'Surrey', | ||
forename: 'Harry', | ||
initials: 'J', | ||
name: 'Primary User test', | ||
postcode: 'WD25 7LR', | ||
role: 'Returns to', | ||
salutation: null, | ||
addressLine1: 'ENVIRONMENT AGENCY', | ||
addressLine2: 'HORIZON HOUSE', | ||
addressLine3: 'DEANERY ROAD', | ||
addressLine4: null | ||
town: 'Little Whinging', | ||
type: 'Person' | ||
} | ||
], | ||
isCurrent: true, | ||
isSummer: true, | ||
Salutation: '', | ||
AddressLine1: 'ENVIRONMENT AGENCY', | ||
AddressLine2: 'HORIZON HOUSE', | ||
AddressLine3: 'DEANERY ROAD', | ||
AddressLine4: '' | ||
isSummer: true | ||
} | ||
} | ||
}) | ||
|
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
Oops, something went wrong.