@defra-fish/sales-api-service 1.49.0-rc.8 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@defra-fish/sales-api-service",
|
|
3
|
-
"version": "1.49.0
|
|
3
|
+
"version": "1.49.0",
|
|
4
4
|
"description": "Rod Licensing Sales API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@defra-fish/business-rules-lib": "1.49.0
|
|
39
|
-
"@defra-fish/connectors-lib": "1.49.0
|
|
40
|
-
"@defra-fish/dynamics-lib": "1.49.0
|
|
38
|
+
"@defra-fish/business-rules-lib": "1.49.0",
|
|
39
|
+
"@defra-fish/connectors-lib": "1.49.0",
|
|
40
|
+
"@defra-fish/dynamics-lib": "1.49.0",
|
|
41
41
|
"@hapi/boom": "^9.1.2",
|
|
42
42
|
"@hapi/hapi": "^20.1.3",
|
|
43
43
|
"@hapi/inert": "^6.0.3",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"moment-timezone": "^0.5.34",
|
|
53
53
|
"uuid": "^8.3.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "22fe7b18f1999903cc973da64ab56a68648dee61"
|
|
56
56
|
}
|
|
@@ -463,6 +463,10 @@ exports[`permissionRenewalData should call preparePermissionDataForRenewal with
|
|
|
463
463
|
Object {
|
|
464
464
|
"id": "d0ece997-ef65-e611-80dc-c4346bad4004",
|
|
465
465
|
"name": "Senior",
|
|
466
|
+
"proof": Object {
|
|
467
|
+
"referenceNumber": "AB 01 02 03 CD",
|
|
468
|
+
"type": "National Insurance Number",
|
|
469
|
+
},
|
|
466
470
|
},
|
|
467
471
|
],
|
|
468
472
|
"dataSource": Object {
|
|
@@ -33,25 +33,16 @@ const permissionForFullReferenceNumberMock = () => ({
|
|
|
33
33
|
entity: MOCK_EXISTING_PERMISSION_ENTITY,
|
|
34
34
|
expanded: {
|
|
35
35
|
licensee: { entity: MOCK_EXISTING_CONTACT_ENTITY, expanded: {} },
|
|
36
|
-
concessionProofs: [{ entity: MOCK_CONCESSION_PROOF_ENTITY }],
|
|
36
|
+
concessionProofs: [{ entity: MOCK_CONCESSION_PROOF_ENTITY, expanded: { concession: { entity: MOCK_CONCESSION } } }],
|
|
37
37
|
permit: { entity: MOCK_1DAY_SENIOR_PERMIT_ENTITY, expanded: {} }
|
|
38
38
|
}
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
const concessionMock = () => ({
|
|
42
|
-
expanded: {
|
|
43
|
-
concession: {
|
|
44
|
-
entity: MOCK_CONCESSION
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
})
|
|
48
|
-
|
|
49
41
|
describe('permissionRenewalData', () => {
|
|
50
42
|
beforeEach(jest.clearAllMocks)
|
|
51
43
|
|
|
52
44
|
it('should call permissionForFullReferenceNumber with referenceNumber', async () => {
|
|
53
45
|
executeQuery.mockResolvedValueOnce([permissionForFullReferenceNumberMock()])
|
|
54
|
-
executeQuery.mockResolvedValueOnce([concessionMock()])
|
|
55
46
|
|
|
56
47
|
const referenceNumber = 'REFERENCE123'
|
|
57
48
|
const request = getMockRequest(referenceNumber)
|
|
@@ -64,13 +55,24 @@ describe('permissionRenewalData', () => {
|
|
|
64
55
|
|
|
65
56
|
it('should call preparePermissionDataForRenewal with the expected data', async () => {
|
|
66
57
|
executeQuery.mockResolvedValueOnce([permissionForFullReferenceNumberMock()])
|
|
67
|
-
executeQuery.mockResolvedValueOnce([concessionMock()])
|
|
68
58
|
|
|
69
59
|
await permissionRenewalData[0].options.handler(getMockRequest(), getMockResponseToolkit())
|
|
70
60
|
|
|
71
61
|
expect(preparePermissionDataForRenewal).toMatchSnapshot()
|
|
72
62
|
})
|
|
73
63
|
|
|
64
|
+
it("omits concession proof reference number if it's not present", async () => {
|
|
65
|
+
const sampleData = permissionForFullReferenceNumberMock()
|
|
66
|
+
sampleData.expanded.concessionProofs[0].entity = {
|
|
67
|
+
type: { label: 'No Proof' }
|
|
68
|
+
}
|
|
69
|
+
executeQuery.mockResolvedValueOnce([sampleData])
|
|
70
|
+
|
|
71
|
+
await permissionRenewalData[0].options.handler(getMockRequest(), getMockResponseToolkit())
|
|
72
|
+
|
|
73
|
+
expect(preparePermissionDataForRenewal.mock.calls[0][0].concessions[0].proof.referenceNumber).toBeUndefined()
|
|
74
|
+
})
|
|
75
|
+
|
|
74
76
|
it('should set concessions to an empty array if concessions is empty', async () => {
|
|
75
77
|
const permissionMock = permissionForFullReferenceNumberMock()
|
|
76
78
|
permissionMock.expanded.concessionProofs = []
|
|
@@ -83,7 +85,6 @@ describe('permissionRenewalData', () => {
|
|
|
83
85
|
|
|
84
86
|
it('should return continue response', async () => {
|
|
85
87
|
executeQuery.mockResolvedValueOnce([permissionForFullReferenceNumberMock()])
|
|
86
|
-
executeQuery.mockResolvedValueOnce([concessionMock()])
|
|
87
88
|
const request = getMockRequest({})
|
|
88
89
|
const responseToolkit = getMockResponseToolkit()
|
|
89
90
|
|
|
@@ -2,7 +2,7 @@ import Boom from '@hapi/boom'
|
|
|
2
2
|
import { preparePermissionDataForRenewal } from '../../services/renewals/renewals.service.js'
|
|
3
3
|
import { permissionRenewalDataRequestParamsSchema, permissionRenewalDataResponseSchema } from '../../schema/renewals.schema.js'
|
|
4
4
|
import db from 'debug'
|
|
5
|
-
import {
|
|
5
|
+
import { permissionForFullReferenceNumber, executeQuery } from '@defra-fish/dynamics-lib'
|
|
6
6
|
const debug = db('sales:permission-renewal-data')
|
|
7
7
|
|
|
8
8
|
const executeWithErrorLog = async query => {
|
|
@@ -16,8 +16,13 @@ const executeWithErrorLog = async query => {
|
|
|
16
16
|
|
|
17
17
|
const getConcessions = async permission => {
|
|
18
18
|
if (permission.expanded.concessionProofs.length) {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
return permission.expanded.concessionProofs.map(cp => ({
|
|
20
|
+
...cp.expanded.concession.entity.toJSON(),
|
|
21
|
+
proof: {
|
|
22
|
+
...(cp.entity.referenceNumber ? { referenceNumber: cp.entity.referenceNumber } : {}),
|
|
23
|
+
type: cp.entity.type.label
|
|
24
|
+
}
|
|
25
|
+
}))
|
|
21
26
|
}
|
|
22
27
|
return []
|
|
23
28
|
}
|