Skip to content

Commit

Permalink
fixes differences api request test by doing object comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
jschuurk-kr committed Jul 12, 2024
1 parent ac6428e commit 0e2ad76
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions frontend/app/component/form/differences/DifferencesForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @vitest-environment jsdom
*/

import { overrideOnce, render, screen, fireEvent } from "app/test/unit";
import { overrideOnce, render, screen, fireEvent, getUrlMethodAndBody } from "app/test/unit";
import { userEvent } from "@testing-library/user-event";
import { describe, expect, test, vi, afterEach } from "vitest";

Expand Down Expand Up @@ -221,13 +221,11 @@ describe("Test DifferencesForm", () => {
const submitButton = screen.getByRole("button", { name: "Volgende" });
await user.click(submitButton);

expect(spy).toHaveBeenCalledWith("http://testhost/v1/api/polling_stations/1/data_entries/1", {
method: "POST",
body: JSON.stringify(expectedRequest),
headers: {
"Content-Type": "application/json",
},
});
expect(spy).toHaveBeenCalled();
const { url, method, body } = getUrlMethodAndBody(spy.mock.calls);
expect(url).toEqual("http://testhost/v1/api/polling_stations/1/data_entries/1");
expect(method).toEqual("POST");
expect(body).toEqual(expectedRequest);

const result = await screen.findByTestId("result");
expect(result).toHaveTextContent(/^Success$/);
Expand Down

0 comments on commit 0e2ad76

Please sign in to comment.