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', () => {
31 .uponReceiving("get root")
38 'Content-Type': 'application/vnd.siren+json'
41 class:[ "representation"],
42 links:[{"rel":["orders"], "href": url("http://localhost:9000", ["orders"]) }]
45 .uponReceiving("get all orders")
52 'Content-Type': 'application/vnd.siren+json'
65 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
72 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
77 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
84 href: url("http://localhost:9000", ["orders"])
89 .uponReceiving("delete order")
92 path: regex("/orders/\\d+", "/orders/1234"),
98 return provider.executeTest(mockserver => {
99 return expect(deleteFirstOrder(mockserver.url)).to.eventually.be.true