Fakultas Ilmu Komputer UI

Commit c8bc956d authored by Muhammad Fairuzi Teguh's avatar Muhammad Fairuzi Teguh
Browse files

[REFACTOR] add rhesus negatif

parent c30bcf98
Pipeline #45037 passed with stages
in 2 minutes and 31 seconds
......@@ -15,7 +15,20 @@ export default function StokDonorChart() {
queryKey => getStokDarah()
)
const series = data
? [{ name: "Darah", data: data.data.map(stok => stok.jumlah_stok) }]
? [
{
name: "Rhesus Positif",
data: data.data
.filter(stok => stok.tipe.includes("+"))
.map(stok => stok.jumlah_stok),
},
{
name: "Rhesus Negatif",
data: data.data
.filter(stok => stok.tipe.includes("-"))
.map(stok => stok.jumlah_stok),
},
]
: []
return (
......
......@@ -9,9 +9,13 @@ import { getStokDarah } from "../api"
import StokDonorChart from "./stokdonorchart"
describe(`Stok Donor`, () => {
it("renders properly", () => {
it("renders properly", async () => {
getStokDarah.mockResolvedValueOnce({
data: [{ tipe: "A-", jumlah_stok: 10 }],
})
const { getByText } = render(<StokDonorChart />)
expect(getByText(/Stok Darah PMI Depok/)).toBeInTheDocument()
await waitForElementToBeRemoved(() => getByText("Loading..."))
})
it(`Show "Coba lagi" button if failing on load the data and then if success show the result`, async () => {
......@@ -21,7 +25,7 @@ describe(`Stok Donor`, () => {
expect(buttonRetry).toBeInTheDocument()
getStokDarah.mockResolvedValueOnce({
data: [{ type: "A", jumlah_stok: "100" }],
data: [{ tipe: "A+", jumlah_stok: "100" }],
})
fireEvent.click(buttonRetry)
await waitForElementToBeRemoved(() => screen.queryByText("Coba lagi"))
......
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