Created
October 29, 2019 15:54
-
-
Save goldbergyoni/1b3ec325ad7138e927cd4fb9b17eca43 to your computer and use it in GitHub Desktop.
Black-box component test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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