Fakultas Ilmu Komputer UI

Commit 45896c2a authored by FadhilP's avatar FadhilP
Browse files

[RED] Add test for invalid date

parent 6b79d590
......@@ -94,4 +94,31 @@ test("Test tanggal form required", async () => {
expect(formBatch.textContent).toContain(
"Tanggal berakhir tidak boleh kosong"
);
});
\ No newline at end of file
});
test("Test tanggal mulai lebih dari tanggal akhir", async () => {
const wrapper = render(
<AuthContext.Provider value={{ profile: { token: "BEBAS" } }}>
<TambahBatch />
</AuthContext.Provider>
);
const startDateMoment = moment("Fri Apr 17 2021 00:00:00 GMT+0700")
const endDateMoment = moment("Sat Apr 16 2021 00:00:00 GMT+0700")
const name_batch = wrapper.getByTestId("name-batch-input");
const start_date = wrapper.getByTitle("start-date-title");
const end_date = wrapper.getByTitle("end-date-title");
await act(async () => {
await fireEvent.input(name_batch, { target: { value: "test" } });
});
await act(async () => {
await fireEvent.input(start_date, { target: { value: startDateMoment } });
});
await act(async () => {
await fireEvent.input(end_date, { target: { value: endDateMoment } });
});
await act(async () => {
await fireEvent.submit(wrapper.getByTestId("submit-batch"));
});
const batch = wrapper.getByTestId("tambah-batch");
expect(batch.textContent).toContain("Tanggal mulai tidak boleh melebihi tanggal akhir!");
})
\ No newline at end of file
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