Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it("accepts a valid event", () => {
return messagePact
.expectsToReceive("a request to save an event")
.withContent({
id: like(1),
event: like("something important"),
type: term({ generate: "save", matcher: "^(save|update|cancel)$" }),
})
.withMetadata({
"content-type": "application/json",
})
.verify(synchronousBodyHandler(consumeEvent))
})
})
it("should accept a valid hero created message", (done) => {
messagePact
.expectsToReceive("a hero created message")
.withContent({
id: Matchers.like(42),
name: Matchers.like("Superman"),
superpower: Matchers.like("flying"),
universe: Matchers.term({generate: "DC", matcher: "^(DC|Marvel)$"})
})
.withMetadata({
"content-type": "application/json",
})
.verify(synchronousBodyHandler(HeroEventHandler.handleHeroCreatedEvent))
.then(() => done(), (error) => done(error));
}).timeout(5000);
it.skip("Does not accept an invalid dog", () => {
return messagePact
.given("some state")
.expectsToReceive("a request for a dog")
.withContent({
name: "fido",
})
.withMetadata({
"content-type": "application/json",
})
.verify(synchronousBodyHandler(dogApiHandler))
})
})