@defra-fish/recurring-payments-job 1.49.0-rc.1 → 1.49.0-rc.10
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/recurring-payments-job",
|
|
3
|
-
"version": "1.49.0-rc.
|
|
3
|
+
"version": "1.49.0-rc.10",
|
|
4
4
|
"description": "Rod Licensing Recurring Payments Job",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@defra-fish/business-rules-lib": "1.49.0-rc.
|
|
40
|
-
"@defra-fish/connectors-lib": "1.49.0-rc.
|
|
39
|
+
"@defra-fish/business-rules-lib": "1.49.0-rc.10",
|
|
40
|
+
"@defra-fish/connectors-lib": "1.49.0-rc.10",
|
|
41
41
|
"commander": "^7.2.0",
|
|
42
42
|
"moment-timezone": "^0.5.34"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "fac8dbbd7e237e1f417c46bc4d6b138ffc035609"
|
|
45
45
|
}
|
|
@@ -15,6 +15,7 @@ jest.mock('@defra-fish/connectors-lib', () => ({
|
|
|
15
15
|
describe('recurring-payments-processor', () => {
|
|
16
16
|
beforeEach(() => {
|
|
17
17
|
jest.clearAllMocks()
|
|
18
|
+
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
18
19
|
})
|
|
19
20
|
|
|
20
21
|
it('console log displays "Recurring Payments job disabled" when env is false', async () => {
|
|
@@ -27,7 +28,6 @@ describe('recurring-payments-processor', () => {
|
|
|
27
28
|
})
|
|
28
29
|
|
|
29
30
|
it('console log displays "Recurring Payments job enabled" when env is true', async () => {
|
|
30
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
31
31
|
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(jest.fn())
|
|
32
32
|
|
|
33
33
|
await processRecurringPayments()
|
|
@@ -36,7 +36,6 @@ describe('recurring-payments-processor', () => {
|
|
|
36
36
|
})
|
|
37
37
|
|
|
38
38
|
it('get recurring payments is called when env is true', async () => {
|
|
39
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
40
39
|
const date = new Date().toISOString().split('T')[0]
|
|
41
40
|
|
|
42
41
|
await processRecurringPayments()
|
|
@@ -45,7 +44,6 @@ describe('recurring-payments-processor', () => {
|
|
|
45
44
|
})
|
|
46
45
|
|
|
47
46
|
it('console log displays "Recurring Payments found: " when env is true', async () => {
|
|
48
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
49
47
|
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(jest.fn())
|
|
50
48
|
|
|
51
49
|
await processRecurringPayments()
|
|
@@ -54,7 +52,6 @@ describe('recurring-payments-processor', () => {
|
|
|
54
52
|
})
|
|
55
53
|
|
|
56
54
|
it('prepares the data for found recurring payments', async () => {
|
|
57
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
58
55
|
const referenceNumber = Symbol('reference')
|
|
59
56
|
salesApi.getDueRecurringPayments.mockReturnValueOnce([{ expanded: { activePermission: { entity: { referenceNumber } } } }])
|
|
60
57
|
|
|
@@ -64,7 +61,6 @@ describe('recurring-payments-processor', () => {
|
|
|
64
61
|
})
|
|
65
62
|
|
|
66
63
|
it('creates a transaction with the correct data', async () => {
|
|
67
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
68
64
|
salesApi.getDueRecurringPayments.mockReturnValueOnce([{ expanded: { activePermission: { entity: { referenceNumber: '1' } } } }])
|
|
69
65
|
|
|
70
66
|
const isLicenceForYou = Symbol('isLicenceForYou')
|
|
@@ -111,8 +107,40 @@ describe('recurring-payments-processor', () => {
|
|
|
111
107
|
expect(salesApi.createTransaction).toHaveBeenCalledWith(expectedData)
|
|
112
108
|
})
|
|
113
109
|
|
|
110
|
+
it('strips the concession name returned by preparePermissionDataForRenewal before passing to createTransaction', async () => {
|
|
111
|
+
salesApi.getDueRecurringPayments.mockReturnValueOnce([{ expanded: { activePermission: { entity: { referenceNumber: '1' } } } }])
|
|
112
|
+
|
|
113
|
+
salesApi.preparePermissionDataForRenewal.mockReturnValueOnce({
|
|
114
|
+
licensee: {
|
|
115
|
+
countryCode: 'GB-ENG'
|
|
116
|
+
},
|
|
117
|
+
concessions: [
|
|
118
|
+
{
|
|
119
|
+
id: 'abc-123',
|
|
120
|
+
name: 'concession-type-1',
|
|
121
|
+
proof: { type: 'NO-PROOF' }
|
|
122
|
+
}
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
|
|
126
|
+
await processRecurringPayments()
|
|
127
|
+
|
|
128
|
+
expect(salesApi.createTransaction).toHaveBeenCalledWith(
|
|
129
|
+
expect.objectContaining({
|
|
130
|
+
permissions: expect.arrayContaining([
|
|
131
|
+
expect.objectContaining({
|
|
132
|
+
concessions: expect.arrayContaining([
|
|
133
|
+
expect.not.objectContaining({
|
|
134
|
+
name: 'concession-type-1'
|
|
135
|
+
})
|
|
136
|
+
])
|
|
137
|
+
})
|
|
138
|
+
])
|
|
139
|
+
})
|
|
140
|
+
)
|
|
141
|
+
})
|
|
142
|
+
|
|
114
143
|
it('assigns the correct startDate when licenceStartTime is present', async () => {
|
|
115
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
116
144
|
salesApi.getDueRecurringPayments.mockReturnValueOnce([{ expanded: { activePermission: { entity: { referenceNumber: '1' } } } }])
|
|
117
145
|
|
|
118
146
|
salesApi.preparePermissionDataForRenewal.mockReturnValueOnce({
|
|
@@ -131,7 +159,6 @@ describe('recurring-payments-processor', () => {
|
|
|
131
159
|
})
|
|
132
160
|
|
|
133
161
|
it('assigns the correct startDate when licenceStartTime is not present', async () => {
|
|
134
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
135
162
|
salesApi.getDueRecurringPayments.mockReturnValueOnce([{ expanded: { activePermission: { entity: { referenceNumber: '1' } } } }])
|
|
136
163
|
|
|
137
164
|
salesApi.preparePermissionDataForRenewal.mockReturnValueOnce({
|
|
@@ -149,7 +176,6 @@ describe('recurring-payments-processor', () => {
|
|
|
149
176
|
})
|
|
150
177
|
|
|
151
178
|
it('raises an error if createTransaction fails', async () => {
|
|
152
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
153
179
|
salesApi.getDueRecurringPayments.mockReturnValueOnce([{ expanded: { activePermission: { entity: { referenceNumber: '1' } } } }])
|
|
154
180
|
const error = 'Wuh-oh!'
|
|
155
181
|
salesApi.createTransaction.mockImplementationOnce(() => {
|
|
@@ -161,7 +187,6 @@ describe('recurring-payments-processor', () => {
|
|
|
161
187
|
|
|
162
188
|
describe.each([2, 3, 10])('if there are %d recurring payments', count => {
|
|
163
189
|
it('prepares the data for each one', async () => {
|
|
164
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
165
190
|
const references = []
|
|
166
191
|
for (let i = 0; i < count; i++) {
|
|
167
192
|
references.push(Symbol('reference' + i))
|
|
@@ -184,8 +209,6 @@ describe('recurring-payments-processor', () => {
|
|
|
184
209
|
})
|
|
185
210
|
|
|
186
211
|
it('creates a transaction for each one', async () => {
|
|
187
|
-
process.env.RUN_RECURRING_PAYMENTS = 'true'
|
|
188
|
-
|
|
189
212
|
const mockGetDueRecurringPayments = []
|
|
190
213
|
for (let i = 0; i < count; i++) {
|
|
191
214
|
mockGetDueRecurringPayments.push({ expanded: { activePermission: { entity: { referenceNumber: i } } } })
|
|
@@ -194,7 +217,7 @@ describe('recurring-payments-processor', () => {
|
|
|
194
217
|
|
|
195
218
|
const permits = []
|
|
196
219
|
for (let i = 0; i < count; i++) {
|
|
197
|
-
permits.push(Symbol(
|
|
220
|
+
permits.push(Symbol(`permit${i}`))
|
|
198
221
|
}
|
|
199
222
|
|
|
200
223
|
permits.forEach(permit => {
|
|
@@ -40,7 +40,10 @@ const processPermissionData = async referenceNumber => {
|
|
|
40
40
|
issueDate: null,
|
|
41
41
|
licensee: licenseeWithoutCountryCode,
|
|
42
42
|
permitId: data.permitId,
|
|
43
|
-
startDate: prepareStartDate(data)
|
|
43
|
+
startDate: prepareStartDate(data),
|
|
44
|
+
concessions: data.concessions?.map(({ name: _name, ...c }) => ({
|
|
45
|
+
...c
|
|
46
|
+
}))
|
|
44
47
|
}
|
|
45
48
|
]
|
|
46
49
|
}
|