@defra-fish/connectors-lib 1.63.0-rc.9 → 1.64.0-rc.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/connectors-lib",
3
- "version": "1.63.0-rc.9",
3
+ "version": "1.64.0-rc.0",
4
4
  "description": "Shared connectors",
5
5
  "type": "module",
6
6
  "engines": {
@@ -46,5 +46,5 @@
46
46
  "node-fetch": "^2.7.0",
47
47
  "redlock": "^4.2.0"
48
48
  },
49
- "gitHead": "fc11192e1947a9a254138b543c8718ad892f0a15"
49
+ "gitHead": "53e28e0083ecb2c50138497dd15a0570a342eca2"
50
50
  }
@@ -10,14 +10,14 @@ describe('sales-api-connector', () => {
10
10
  describe('call', () => {
11
11
  it('handles get requests with a 200 response', async () => {
12
12
  const expectedResponse = { some: 'data' }
13
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
13
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
14
14
  await expect(salesApi.call(new URL(TEST_HREF))).resolves.toEqual({ ok: true, status: 200, statusText: 'OK', body: expectedResponse })
15
15
  expect(fetch).toHaveBeenCalledWith(TEST_HREF, { method: 'get', headers: expect.any(Object), timeout: 20000 })
16
16
  })
17
17
 
18
18
  it('handles get requests with a 204 response', async () => {
19
19
  const expectedResponse = undefined
20
- fetch.mockReturnValue({ ok: true, status: 204, statusText: 'No Content', text: async () => JSON.stringify(expectedResponse) })
20
+ fetch.mockReturnValueOnce({ ok: true, status: 204, statusText: 'No Content', text: async () => JSON.stringify(expectedResponse) })
21
21
  await expect(salesApi.call(new URL(TEST_HREF))).resolves.toEqual({
22
22
  ok: true,
23
23
  status: 204,
@@ -30,7 +30,7 @@ describe('sales-api-connector', () => {
30
30
  it('handles post requests', async () => {
31
31
  const payload = { example: 'payload' }
32
32
  const expectedResponse = { some: 'data' }
33
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
33
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
34
34
  await expect(salesApi.call(new URL(TEST_HREF), 'post', payload)).resolves.toEqual({
35
35
  ok: true,
36
36
  status: 200,
@@ -47,7 +47,7 @@ describe('sales-api-connector', () => {
47
47
  it('handles patch requests', async () => {
48
48
  const payload = { example: 'payload' }
49
49
  const expectedResponse = { some: 'data' }
50
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
50
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
51
51
  await expect(salesApi.call(new URL(TEST_HREF), 'patch', payload)).resolves.toEqual({
52
52
  ok: true,
53
53
  status: 200,
@@ -62,7 +62,12 @@ describe('sales-api-connector', () => {
62
62
  })
63
63
  })
64
64
  it('returns necessary information on a non-ok response', async () => {
65
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
65
+ fetch.mockReturnValueOnce({
66
+ ok: false,
67
+ status: 404,
68
+ statusText: 'Not Found',
69
+ text: async () => JSON.stringify({ error: 'Description' })
70
+ })
66
71
  await expect(salesApi.call(new URL(TEST_HREF))).resolves.toEqual({
67
72
  ok: false,
68
73
  status: 404,
@@ -76,7 +81,7 @@ describe('sales-api-connector', () => {
76
81
 
77
82
  it('parses response text if a json response cannot be parsed', async () => {
78
83
  const textResponseMethod = jest.fn(async () => 'Text response')
79
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: textResponseMethod })
84
+ fetch.mockReturnValueOnce({ ok: false, status: 404, statusText: 'Not Found', text: textResponseMethod })
80
85
  await expect(salesApi.call(new URL(TEST_HREF))).resolves.toEqual({
81
86
  ok: false,
82
87
  status: 404,
@@ -100,7 +105,7 @@ describe('sales-api-connector', () => {
100
105
  it('creates a single transaction', async () => {
101
106
  const transaction = { some: 'data' }
102
107
  const expectedResponse = { a: 'response' }
103
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
108
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
104
109
  await expect(salesApi.createTransaction(transaction)).resolves.toEqual(expectedResponse)
105
110
  expect(fetch).toHaveBeenCalledWith(
106
111
  'http://0.0.0.0:4000/transactions',
@@ -112,7 +117,12 @@ describe('sales-api-connector', () => {
112
117
  })
113
118
  it('throws on a non-ok response', async () => {
114
119
  const transaction = { some: 'data' }
115
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
120
+ fetch.mockReturnValueOnce({
121
+ ok: false,
122
+ status: 404,
123
+ statusText: 'Not Found',
124
+ text: async () => JSON.stringify({ error: 'Description' })
125
+ })
116
126
  await expect(salesApi.createTransaction(transaction)).rejects.toThrow(
117
127
  /Unexpected response from the Sales API:.*"status": 404.*"statusText": "Not Found"/s
118
128
  )
@@ -130,7 +140,7 @@ describe('sales-api-connector', () => {
130
140
  it('creates multiple transactions in batch', async () => {
131
141
  const transactions = ['a', 'b']
132
142
  const expectedResponse = [{}, {}]
133
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
143
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
134
144
  await expect(salesApi.createTransactions(transactions)).resolves.toEqual(expectedResponse)
135
145
  expect(fetch).toHaveBeenCalledWith(
136
146
  'http://0.0.0.0:4000/transactions/$batch',
@@ -142,7 +152,12 @@ describe('sales-api-connector', () => {
142
152
  })
143
153
  it('throws on a non-ok response', async () => {
144
154
  const transactions = ['a', 'b']
145
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
155
+ fetch.mockReturnValueOnce({
156
+ ok: false,
157
+ status: 404,
158
+ statusText: 'Not Found',
159
+ text: async () => JSON.stringify({ error: 'Description' })
160
+ })
146
161
  await expect(salesApi.createTransactions(transactions)).rejects.toThrow(
147
162
  /Unexpected response from the Sales API:.*"status": 404.*"statusText": "Not Found"/s
148
163
  )
@@ -168,7 +183,7 @@ describe('sales-api-connector', () => {
168
183
  }
169
184
  }
170
185
  const expectedResponse = { messageId: 'example', status: 'queued' }
171
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
186
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
172
187
  await expect(salesApi.finaliseTransaction(transactionId, payload)).resolves.toEqual(expectedResponse)
173
188
  expect(fetch).toHaveBeenCalledWith(
174
189
  `http://0.0.0.0:4000/transactions/${transactionId}`,
@@ -189,7 +204,12 @@ describe('sales-api-connector', () => {
189
204
  method: 'Debit card'
190
205
  }
191
206
  }
192
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
207
+ fetch.mockReturnValueOnce({
208
+ ok: false,
209
+ status: 404,
210
+ statusText: 'Not Found',
211
+ text: async () => JSON.stringify({ error: 'Description' })
212
+ })
193
213
  await expect(salesApi.finaliseTransaction(transactionId, payload)).rejects.toThrow(
194
214
  /Unexpected response from the Sales API:.*"status": 404.*"statusText": "Not Found"/s
195
215
  )
@@ -206,7 +226,7 @@ describe('sales-api-connector', () => {
206
226
  describe('getTransactionFile', () => {
207
227
  it('retrieves details of an existing transaction file', async () => {
208
228
  const expectedResponse = { some: 'data' }
209
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
229
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
210
230
  await expect(salesApi.getTransactionFile('test.xml')).resolves.toEqual(expectedResponse)
211
231
  expect(fetch).toHaveBeenCalledWith(
212
232
  'http://0.0.0.0:4000/transaction-files/test.xml',
@@ -216,7 +236,12 @@ describe('sales-api-connector', () => {
216
236
  )
217
237
  })
218
238
  it('returns null if none found', async () => {
219
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
239
+ fetch.mockReturnValueOnce({
240
+ ok: false,
241
+ status: 404,
242
+ statusText: 'Not Found',
243
+ text: async () => JSON.stringify({ error: 'Description' })
244
+ })
220
245
  await expect(salesApi.getTransactionFile('test.xml')).resolves.toBeNull()
221
246
  expect(fetch).toHaveBeenCalledWith(
222
247
  'http://0.0.0.0:4000/transaction-files/test.xml',
@@ -230,7 +255,7 @@ describe('sales-api-connector', () => {
230
255
  describe('upsertTransactionFile', () => {
231
256
  it('updates the details of a given transaction file', async () => {
232
257
  const expectedResponse = { some: 'data' }
233
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
258
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
234
259
  await expect(salesApi.upsertTransactionFile('test.xml')).resolves.toEqual(expectedResponse)
235
260
  expect(fetch).toHaveBeenCalledWith(
236
261
  'http://0.0.0.0:4000/transaction-files/test.xml',
@@ -240,7 +265,7 @@ describe('sales-api-connector', () => {
240
265
  )
241
266
  })
242
267
  it('throws on a non-ok response', async () => {
243
- fetch.mockReturnValue({
268
+ fetch.mockReturnValueOnce({
244
269
  ok: false,
245
270
  status: 422,
246
271
  statusText: 'Unprocessable Entity',
@@ -261,7 +286,7 @@ describe('sales-api-connector', () => {
261
286
  describe('getPaymentJournal', () => {
262
287
  it('retrieves details of an existing payment journal', async () => {
263
288
  const expectedResponse = { some: 'data' }
264
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
289
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
265
290
  await expect(salesApi.getPaymentJournal('test-id')).resolves.toEqual(expectedResponse)
266
291
  expect(fetch).toHaveBeenCalledWith(
267
292
  'http://0.0.0.0:4000/paymentJournals/test-id',
@@ -271,7 +296,12 @@ describe('sales-api-connector', () => {
271
296
  )
272
297
  })
273
298
  it('returns null if none found', async () => {
274
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
299
+ fetch.mockReturnValueOnce({
300
+ ok: false,
301
+ status: 404,
302
+ statusText: 'Not Found',
303
+ text: async () => JSON.stringify({ error: 'Description' })
304
+ })
275
305
  await expect(salesApi.getPaymentJournal('test-id')).resolves.toBeNull()
276
306
  expect(fetch).toHaveBeenCalledWith(
277
307
  'http://0.0.0.0:4000/paymentJournals/test-id',
@@ -286,7 +316,7 @@ describe('sales-api-connector', () => {
286
316
  it('creates a new payment journal', async () => {
287
317
  const payload = { some: 'data' }
288
318
  const expectedResponse = { a: 'response' }
289
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
319
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
290
320
  await expect(salesApi.createPaymentJournal('test-id', payload)).resolves.toEqual(expectedResponse)
291
321
  expect(fetch).toHaveBeenCalledWith(
292
322
  'http://0.0.0.0:4000/paymentJournals/test-id',
@@ -298,7 +328,7 @@ describe('sales-api-connector', () => {
298
328
  })
299
329
  it('throws on a non-ok response', async () => {
300
330
  const payload = { some: 'data' }
301
- fetch.mockReturnValue({
331
+ fetch.mockReturnValueOnce({
302
332
  ok: false,
303
333
  status: 422,
304
334
  statusText: 'Unprocessable Entity',
@@ -320,7 +350,7 @@ describe('sales-api-connector', () => {
320
350
  describe('updatePaymentJournal', () => {
321
351
  it('updates the details of a given transaction file', async () => {
322
352
  const expectedResponse = { some: 'data' }
323
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
353
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
324
354
  await expect(salesApi.updatePaymentJournal('test-id')).resolves.toEqual(expectedResponse)
325
355
  expect(fetch).toHaveBeenCalledWith(
326
356
  'http://0.0.0.0:4000/paymentJournals/test-id',
@@ -330,7 +360,7 @@ describe('sales-api-connector', () => {
330
360
  )
331
361
  })
332
362
  it('throws on a non-ok response', async () => {
333
- fetch.mockReturnValue({
363
+ fetch.mockReturnValueOnce({
334
364
  ok: false,
335
365
  status: 422,
336
366
  statusText: 'Unprocessable Entity',
@@ -352,7 +382,7 @@ describe('sales-api-connector', () => {
352
382
  it('creates a new staging exception', async () => {
353
383
  const payload = { some: 'data' }
354
384
  const expectedResponse = { a: 'response' }
355
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
385
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
356
386
  await expect(salesApi.createStagingException(payload)).resolves.toEqual(expectedResponse)
357
387
  expect(fetch).toHaveBeenCalledWith(
358
388
  'http://0.0.0.0:4000/stagingExceptions',
@@ -364,7 +394,7 @@ describe('sales-api-connector', () => {
364
394
  })
365
395
  it('throws on a non-ok response', async () => {
366
396
  const payload = { some: 'data' }
367
- fetch.mockReturnValue({
397
+ fetch.mockReturnValueOnce({
368
398
  ok: false,
369
399
  status: 422,
370
400
  statusText: 'Unprocessable Entity',
@@ -386,7 +416,7 @@ describe('sales-api-connector', () => {
386
416
  describe('getPoclValidationErrorsForProcessing', () => {
387
417
  it('creates a new staging exception', async () => {
388
418
  const expectedResponse = { a: 'response' }
389
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
419
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
390
420
  await expect(salesApi.getPoclValidationErrorsForProcessing()).resolves.toEqual(expectedResponse)
391
421
  expect(fetch).toHaveBeenCalledWith(
392
422
  'http://0.0.0.0:4000/poclValidationErrors',
@@ -396,7 +426,7 @@ describe('sales-api-connector', () => {
396
426
  )
397
427
  })
398
428
  it('throws on a non-ok response', async () => {
399
- fetch.mockReturnValue({
429
+ fetch.mockReturnValueOnce({
400
430
  ok: false,
401
431
  status: 422,
402
432
  statusText: 'Unprocessable Entity',
@@ -419,7 +449,7 @@ describe('sales-api-connector', () => {
419
449
  const id = 'test-id'
420
450
  const payload = { some: 'data' }
421
451
  const expectedResponse = { a: 'response' }
422
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
452
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
423
453
  await expect(salesApi.updatePoclValidationError(id, payload)).resolves.toEqual(expectedResponse)
424
454
  expect(fetch).toHaveBeenCalledWith(
425
455
  'http://0.0.0.0:4000/poclValidationErrors/test-id',
@@ -432,7 +462,7 @@ describe('sales-api-connector', () => {
432
462
  it('throws on a non-ok response', async () => {
433
463
  const id = 'test-id'
434
464
  const payload = { some: 'data' }
435
- fetch.mockReturnValue({
465
+ fetch.mockReturnValueOnce({
436
466
  ok: false,
437
467
  status: 422,
438
468
  statusText: 'Unprocessable Entity',
@@ -454,7 +484,7 @@ describe('sales-api-connector', () => {
454
484
  describe('getSystemUser', () => {
455
485
  it('retrieves details of a system user', async () => {
456
486
  const expectedResponse = { some: 'data' }
457
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
487
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
458
488
  await expect(salesApi.getSystemUser('test-id')).resolves.toEqual(expectedResponse)
459
489
  expect(fetch).toHaveBeenCalledWith(
460
490
  'http://0.0.0.0:4000/systemUsers/test-id',
@@ -464,7 +494,12 @@ describe('sales-api-connector', () => {
464
494
  )
465
495
  })
466
496
  it('returns null if none found', async () => {
467
- fetch.mockReturnValue({ ok: false, status: 404, statusText: 'Not Found', text: async () => JSON.stringify({ error: 'Description' }) })
497
+ fetch.mockReturnValueOnce({
498
+ ok: false,
499
+ status: 404,
500
+ statusText: 'Not Found',
501
+ text: async () => JSON.stringify({ error: 'Description' })
502
+ })
468
503
  await expect(salesApi.getSystemUser('test-id')).resolves.toBeNull()
469
504
  expect(fetch).toHaveBeenCalledWith(
470
505
  'http://0.0.0.0:4000/systemUsers/test-id',
@@ -481,7 +516,7 @@ describe('sales-api-connector', () => {
481
516
  endpoint => {
482
517
  it('retrieves all items using .getAll()', async () => {
483
518
  const expectedResponse = [{ id: 'test-1' }, { id: 'test-2' }]
484
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
519
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
485
520
  await expect(salesApi[endpoint].getAll()).resolves.toEqual(expectedResponse)
486
521
  expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/${endpoint}?`, {
487
522
  method: 'get',
@@ -495,7 +530,7 @@ describe('sales-api-connector', () => {
495
530
  { id: 'test-1', set: '1' },
496
531
  { id: 'test-2', set: '1' }
497
532
  ]
498
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
533
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
499
534
  await expect(salesApi[endpoint].getAll({ set: '1' })).resolves.toEqual(expectedResponse)
500
535
  expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/${endpoint}?set=1`, {
501
536
  method: 'get',
@@ -510,7 +545,7 @@ describe('sales-api-connector', () => {
510
545
  { id: 'test-2', set: '1' }
511
546
  ]
512
547
  const expectedResponse = { id: 'test-1', set: '1' }
513
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(apiResponse) })
548
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(apiResponse) })
514
549
  await expect(salesApi[endpoint].find({ set: '1' })).resolves.toEqual(expectedResponse)
515
550
  expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/${endpoint}?set=1`, {
516
551
  method: 'get',
@@ -520,7 +555,7 @@ describe('sales-api-connector', () => {
520
555
  })
521
556
 
522
557
  it('throws if given a non-ok response code when calling .getAll()', async () => {
523
- fetch.mockReturnValue({
558
+ fetch.mockReturnValueOnce({
524
559
  ok: false,
525
560
  status: 404,
526
561
  statusText: 'Not Found',
@@ -537,7 +572,7 @@ describe('sales-api-connector', () => {
537
572
  })
538
573
 
539
574
  it('throws if given a non-ok response code when calling .find(criteria)', async () => {
540
- fetch.mockReturnValue({
575
+ fetch.mockReturnValueOnce({
541
576
  ok: false,
542
577
  status: 404,
543
578
  statusText: 'Not Found',
@@ -554,7 +589,7 @@ describe('sales-api-connector', () => {
554
589
  })
555
590
 
556
591
  it('returns undefined if no item could be found using .find(criteria)', async () => {
557
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify([]) })
592
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify([]) })
558
593
  await expect(salesApi[endpoint].find({ set: '1' })).resolves.toEqual(undefined)
559
594
  expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/${endpoint}?set=1`, {
560
595
  method: 'get',
@@ -569,7 +604,7 @@ describe('sales-api-connector', () => {
569
604
  describe('country endpoint', () => {
570
605
  it('retrieves all items using .getAll()', async () => {
571
606
  const expectedResponse = [{ id: 'test-1' }, { id: 'test-2' }]
572
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
607
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
573
608
  await expect(salesApi.countries.getAll()).resolves.toEqual(expectedResponse)
574
609
  expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/option-sets/defra_country?', {
575
610
  method: 'get',
@@ -582,7 +617,7 @@ describe('sales-api-connector', () => {
582
617
  describe('authentication', () => {
583
618
  it('retrieves all items using .getAll()', async () => {
584
619
  const expectedResponse = { foo: 'bar' }
585
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
620
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
586
621
  await expect(salesApi.authenticate('AAAAAA', '1980-03-02', 'BS9 4PT')).resolves.toEqual(expectedResponse)
587
622
  expect(fetch).toHaveBeenCalledWith(
588
623
  'http://0.0.0.0:4000/authenticate/renewal/AAAAAA?licenseeBirthDate=1980-03-02&licenseePostcode=BS9%204PT',
@@ -618,7 +653,7 @@ describe('sales-api-connector', () => {
618
653
  ]
619
654
  }
620
655
 
621
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
656
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
622
657
 
623
658
  await expect(salesApi.getDueRecurringPayments(date)).resolves.toEqual(expectedResponse)
624
659
  })
@@ -632,7 +667,7 @@ describe('sales-api-connector', () => {
632
667
  ]
633
668
  }
634
669
 
635
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
670
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
636
671
 
637
672
  await salesApi.getDueRecurringPayments(date)
638
673
 
@@ -647,7 +682,7 @@ describe('sales-api-connector', () => {
647
682
  describe('preparePermissionDataForRenewal', () => {
648
683
  it('retrieves all items using .getAll()', async () => {
649
684
  const expectedResponse = { foo: 'bar' }
650
- fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
685
+ fetch.mockReturnValueOnce({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
651
686
  await expect(salesApi.preparePermissionDataForRenewal('AAAAAA')).resolves.toEqual(expectedResponse)
652
687
  expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/permissionRenewalData/AAAAAA', {
653
688
  method: 'get',
@@ -663,7 +698,7 @@ describe('sales-api-connector', () => {
663
698
  ['abc-123', 'def-456', '2025-02-15T23:49:32.386Z']
664
699
  ])("Processing payment for transaction id '%s'", (transactionId, paymentId, createdDate) => {
665
700
  beforeEach(() => {
666
- fetch.mockReturnValue({
701
+ fetch.mockReturnValueOnce({
667
702
  ok: true,
668
703
  status: 200,
669
704
  statusText: 'OK',
@@ -689,7 +724,7 @@ describe('sales-api-connector', () => {
689
724
  })
690
725
 
691
726
  it('throws an error on non-2xx response', async () => {
692
- fetch.mockReturnValue({
727
+ fetch.mockReturnValueOnce({
693
728
  ok: false,
694
729
  status: 500,
695
730
  statusText: 'Internal Server Error',
@@ -710,7 +745,7 @@ describe('sales-api-connector', () => {
710
745
  describe('cancelRecurringPayment', () => {
711
746
  describe.each([['id'], ['abc-123']])("Cancelling recurring payment id '%s'", id => {
712
747
  beforeEach(() => {
713
- fetch.mockReturnValue({
748
+ fetch.mockReturnValueOnce({
714
749
  ok: true,
715
750
  status: 200,
716
751
  statusText: 'OK',
@@ -736,7 +771,7 @@ describe('sales-api-connector', () => {
736
771
  })
737
772
 
738
773
  it('throws an error on non-2xx response', async () => {
739
- fetch.mockReturnValue({
774
+ fetch.mockReturnValueOnce({
740
775
  ok: false,
741
776
  status: 500,
742
777
  statusText: 'Internal Server Error',
@@ -750,7 +785,7 @@ describe('sales-api-connector', () => {
750
785
  describe('retrieveStagedTransaction', () => {
751
786
  describe.each([['id'], ['abc-123']])("Retrieving staged transaction id '%s'", id => {
752
787
  beforeEach(() => {
753
- fetch.mockReturnValue({
788
+ fetch.mockReturnValueOnce({
754
789
  ok: true,
755
790
  status: 200,
756
791
  statusText: 'OK',
@@ -776,7 +811,7 @@ describe('sales-api-connector', () => {
776
811
  })
777
812
 
778
813
  it('throws an error on non-2xx response', async () => {
779
- fetch.mockReturnValue({
814
+ fetch.mockReturnValueOnce({
780
815
  ok: false,
781
816
  status: 500,
782
817
  statusText: 'Internal Server Error',