1 const path = require("path")
2 const chai = require("chai")
3 const chaiAsPromised = require("chai-as-promised")
4 const expect = chai.expect
5 const { PactV3, MatchersV3 } = require("@pact-foundation/pact/v3")
6 const { deleteFirstOrder } = require('../consumer')
8 chai.use(chaiAsPromised)
18 describe("Siren Pact test", () => {
22 provider = new PactV3({
23 consumer: "Siren Order Provider",
24 provider: "Siren Order Service",
25 dir: path.resolve(process.cwd(), "pacts")
29 it('deletes the first order using the delete action', () => {
33 .uponReceiving("get root")
41 'Content-Type': 'application/vnd.siren+json'
44 class: [ "representation"],
45 links: [{"rel":["orders"], "href": url(["orders"]) }]
50 .uponReceiving("get all orders")
58 'Content-Type': 'application/vnd.siren+json'
71 "href": url(["orders", regex("\\d+", "1234")])
74 "actions": arrayContaining(
78 "href": url(["orders", regex("\\d+", "1234")])
83 "href": url(["orders", regex("\\d+", "1234")])
96 // Delete Order Request
97 .uponReceiving("delete order")
100 path: regex("/orders/\\d+", "/orders/1234"),
106 return provider.executeTest(mockserver => {
107 return expect(deleteFirstOrder(mockserver.url)).to.eventually.be.true