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",
26 dir: path.resolve(process.cwd(), "pacts")
30 it('deletes the first order using the delete action', () => {
34 .uponReceiving("get root")
41 'Content-Type': 'application/vnd.siren+json'
44 class:[ "representation"],
45 links:[{"rel":["orders"], "href": url("http://localhost:9000", ["orders"]) }]
50 .uponReceiving("get all orders")
57 'Content-Type': 'application/vnd.siren+json'
70 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
73 "actions": arrayContaining(
77 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
82 "href": url("http://localhost:9000", ["orders", regex("\\d+", "1234")])
89 href: url("http://localhost:9000", ["orders"])
95 // Delete Order Request
96 .uponReceiving("delete order")
99 path: regex("/orders/\\d+", "/orders/1234"),
105 return provider.executeTest(mockserver => {
106 return expect(deleteFirstOrder(mockserver.url)).to.eventually.be.true