|
| 1 | +import path from 'node:path'; |
| 2 | +import { MessageProviderPact } from '@pact-foundation/pact'; |
| 3 | +import LetterAcceptedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.ACCEPTED.json'; |
| 4 | +import LetterCancelledEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.CANCELLED.json'; |
| 5 | +import LetterDeliveredEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.DELIVERED.json'; |
| 6 | +import LetterDispatchedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.DISPATCHED.json'; |
| 7 | +import LetterEnclosedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.ENCLOSED.json'; |
| 8 | +import LetterFailedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.FAILED.json'; |
| 9 | +import LetterForwardedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.FORWARDED.json'; |
| 10 | +import LetterPendingEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.PENDING.json'; |
| 11 | +import LetterPrintedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.PRINTED.json'; |
| 12 | +import LetterRejectedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.REJECTED.json'; |
| 13 | +import LetterReturnedEvent from '@nhsdigital/nhs-notify-event-schemas-supplier-api/schemas/examples/letter.RETURNED.json'; |
| 14 | + |
| 15 | +describe('Supplier API -> Digital Letters pact tests', () => { |
| 16 | + test('verify pacts', async () => { |
| 17 | + const p = new MessageProviderPact({ |
| 18 | + provider: 'ssupplier-api', |
| 19 | + pactUrls: [ |
| 20 | + path.join( |
| 21 | + __dirname, |
| 22 | + '../../../node_modules', |
| 23 | + '@nhsdigital/notify-digital-letters-consumer-contracts/pacts/supplier-api/digital-letters-supplier-api.json' |
| 24 | + ), |
| 25 | + ], |
| 26 | + messageProviders: { |
| 27 | + 'SupplierApiEvent-letter_accepted': () => LetterAcceptedEvent, |
| 28 | + 'SupplierApiEvent-letter_cancelled': () => LetterCancelledEvent, |
| 29 | + 'SupplierApiEvent-letter_delivered': () => LetterDeliveredEvent, |
| 30 | + 'SupplierApiEvent-letter_dispatched': () => LetterDispatchedEvent, |
| 31 | + 'SupplierApiEvent-letter_enclosed': () => LetterEnclosedEvent, |
| 32 | + 'SupplierApiEvent-letter_failed': () => LetterFailedEvent, |
| 33 | + 'SupplierApiEvent-letter_forwarded': () => LetterForwardedEvent, |
| 34 | + 'SupplierApiEvent-letter_pending': () => LetterPendingEvent, |
| 35 | + 'SupplierApiEvent-letter_printed': () => LetterPrintedEvent, |
| 36 | + 'SupplierApiEvent-letter_rejected': () => LetterRejectedEvent, |
| 37 | + 'SupplierApiEvent-letter_returned': () => LetterReturnedEvent, |
| 38 | + }, |
| 39 | + logLevel: 'error', |
| 40 | + }); |
| 41 | + |
| 42 | + await expect(p.verify()).resolves.not.toThrow(); |
| 43 | + }, 60_000); |
| 44 | +}); |
0 commit comments