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)
17 describe("Siren Pact test", () => {
21 provider = new PactV3({
22 consumer: "Siren Order Provider",
23 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")
40 'Content-Type': 'application/vnd.siren+json'
43 class:[ "representation"],
44 links:[{"rel":["orders"], "href": url("http://localhost:9000", ["orders"]) }]
49 .uponReceiving("get all orders")
56 'Content-Type': 'application/vnd.siren+json'
69 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
76 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
81 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
88 href: url("http://localhost:9000", ["orders"])
94 // Delete Order Request
95 .uponReceiving("delete order")
98 path: regex("/orders/\\d+", "/orders/1234"),
104 return provider.executeTest(mockserver => {
105 return expect(deleteFirstOrder(mockserver.url)).to.eventually.be.true