Fakultas Ilmu Komputer UI

Commit 7b9bfc14 authored by Yasmin Adelia Puti Chaidir's avatar Yasmin Adelia Puti Chaidir
Browse files

[RED] add kode kbli validation test

parent 937c5c1d
Pipeline #72729 failed with stages
in 10 minutes and 18 seconds
import {
screen,
waitFor,
fireEvent,
waitForElementToBeRemoved,
} from '@testing-library/react'
......@@ -34,3 +35,47 @@ test('renders FormIUMK2 element', async () => {
expect(screen.getByTestId('form-iumk-2-kode-kbli')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-2-catatan')).toBeInTheDocument()
})
test('kode KBLI error if length is not five', async () => {
const store = makeTestStore()
testRender(<FormIUMK />, {store})
userEvent.selectOptions(screen.getByTestId('form-iumk-2-dropdown'), '1-10')
expect(screen.getByTestId('form-iumk-2-dropdown')).toHaveValue('1-10')
const kodeKbliInput = screen.getByLabelText(/Kode KBLI/i)
fireEvent.change(kodeKbliInput, {
target: {value: '111044'},
})
const lanjutButton = screen.getByTestId('lanjut-button')
fireEvent.click(lanjutButton)
await waitFor(() => {
expect(screen.getByText(/Kode KBLI harus terdiri dari 5 angka/i)).toBeInTheDocument()
})
})
test('kode KBLI error if contains character other than number', async () => {
const store = makeTestStore()
testRender(<FormIUMK />, {store})
userEvent.selectOptions(screen.getByTestId('form-iumk-2-dropdown'), '1-10')
expect(screen.getByTestId('form-iumk-2-dropdown')).toHaveValue('1-10')
const kodeKbliInput = screen.getByLabelText(/Kode KBLI/i)
fireEvent.change(kodeKbliInput, {
target: {value: '111ab'},
})
const lanjutButton = screen.getByTestId('lanjut-button')
fireEvent.click(lanjutButton)
await waitFor(() => {
expect(screen.getByText(/Kode KBLI hanya boleh mengandung angka/i)).toBeInTheDocument()
})
})
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