Fakultas Ilmu Komputer UI

Commit bea21f3c authored by Shella Gabriella's avatar Shella Gabriella
Browse files

[RED] memperbaiki test transaksi

parent ed710f00
Pipeline #82027 failed with stages
in 2 minutes and 56 seconds
import { cleanup, render } from "@testing-library/react";
import AuthContext from "../../utils/contex";
import React from "react";
import DetailTransaksi from "../../page/transaksi/DetailTransaksi";
import { waitFor } from "@testing-library/dom";
beforeEach(() => {
fetch.resetMocks();
});
afterEach(cleanup);
test("Test detail loaded transaksi", async () => {
fetch.mockResponseOnce(
JSON.stringify({
id: "8e9a8f94-cb5c-4b2d-b4f1-81ccfb9f1b0a",
transaction_number: "7NGVBN",
user: "45897cc5-968c-44cf-931d-e646b095fcaf",
user_username: "admin-staging",
program: "6d7462da-6a85-4e2b-9930-69567090a5d5",
program_code: "3MXZ9T",
user_full_name: "Hello",
user_phone_number: "012345",
program_name: "dummy 2",
hampers_messages: "",
hampers_price: "0.00",
created_at: "2020-04-28T21:34:15.565614+07:00",
updated_at: "2020-04-28T21:34:15.565651+07:00",
})
);
const { getByTestId } = render(
<AuthContext.Provider value={{ profile: { token: "tester" } }}>
<DetailTransaksi idTransaksi={"8e9a8f94-cb5c-4b2d-b4f1-81ccfb9f1b0a"} />
</AuthContext.Provider>
);
const wait = getByTestId("waiting-detail-transaksi");
expect(wait.textContent).toContain("Fetching data..");
await waitFor(() => getByTestId("page-detail-transaksi"));
const data = getByTestId("page-detail-transaksi");
expect(data.textContent).toContain("KELOLA TRANSAKSI");
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment