Fakultas Ilmu Komputer UI

Commit e51b23e3 authored by Nabila Febri Viola's avatar Nabila Febri Viola
Browse files

[REFACTOR] Fix riwayat acara donor tests

parent bd46a3cf
......@@ -295,7 +295,7 @@ describe("Riwayat Acara Donor", () => {
results: [
{
id: 1,
status: "false",
status: false,
alamat_institusi: "Pacilkom",
alamat_lokasi_donor: "Sekre Pacil",
email_kantor: "pacil@cs.ui.ac.id",
......@@ -315,9 +315,9 @@ describe("Riwayat Acara Donor", () => {
},
})
renderAuthenticated(<ProfilePage />)
await screen.findByText("Lokasi")
await screen.findByText("Alamat")
expect(screen.getByText("Sekre Pacil"))
expect(screen.getByText("2 Juni 2020, (10:00 - 12:00)"))
expect(screen.getByText("2 Juni 2020, (12:00 - 10:00)")).toBeInTheDocument()
expect(screen.getByText("Ditolak"))
await waitFor(() =>
expect(screen.queryByText("Loading...")).not.toBeInTheDocument()
......@@ -347,7 +347,7 @@ describe("Riwayat Acara Donor", () => {
.mockResolvedValueOnce({
data: {
count: 4,
results: [acara_donor4, acaraDonorFactory(), acaraDonorFactory()],
results: [acara_donor1, acaraDonorFactory(), acaraDonorFactory()],
},
})
.mockResolvedValueOnce({
......@@ -363,19 +363,23 @@ describe("Riwayat Acara Donor", () => {
fireEvent.click(screen.getByText("Halaman sebelumnya riwayat acara donor"))
expect(await screen.findByText("Yuli Pacil")).toBeInTheDocument()
fireEvent.click(screen.getByText("Halaman selanjutnya riwayat acara donor"))
expect(await screen.findByText("Gedung baru Fasilkom")).toBeInTheDocument()
expect(await screen.findByText("Belyos Pacil")).toBeInTheDocument()
await waitFor(() =>
expect(screen.queryByText("Loading...")).not.toBeInTheDocument()
)
})
it("shows retry button on error and can be retried", async () => {
getRiwayatDonor
getRiwayatAcaraDonor
.mockRejectedValueOnce(new Error("Network error"))
.mockResolvedValueOnce({
data: {
count: 1,
results: [acaraDonorFactory({ alamat_lokasi_donor: "Yuli Pacil" })],
results: [
acaraDonorFactory({
alamat_lokasi_donor: "Yuli Pacil",
}),
],
},
})
renderAuthenticated(<ProfilePage />)
......
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