Skip to content

Instantly share code, notes, and snippets.

@goldbergyoni
Created October 29, 2019 15:54
Show Gist options
  • Select an option

  • Save goldbergyoni/1b3ec325ad7138e927cd4fb9b17eca43 to your computer and use it in GitHub Desktop.

Select an option

Save goldbergyoni/1b3ec325ad7138e927cd4fb9b17eca43 to your computer and use it in GitHub Desktop.
Black-box component test
test("When adding a new valid order , Then should get back 200 response", async () => {
//Arrange
const orderToAdd = {userId: 1, productId: 2, mode: 'approved'};
nock("http://localhost/user/")
.get(`/1`).reply(200, {
id: 1, name: "John"
});
//Act
const receivedAPIResponse = await superTest(expressApp).post("/order").send(orderToAdd);
//Assert
const {status,body} = receivedAPIResponse;
expect({status,body}).toMatchObject({
status: 200,
body: {
mode: 'approved'
}
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment