Fakultas Ilmu Komputer UI

Commit 78b70bfc authored by Shafiya Adzhani's avatar Shafiya Adzhani
Browse files

[CHORES] fix error test in form iumk 3

parent 3834208e
Pipeline #72321 passed with stages
in 6 minutes and 9 seconds
......@@ -7,7 +7,7 @@ import FormIUMK from '../../pages/formiumk'
import {testRender, makeTestStore, fixtureSet} from '../../testUtils'
import userEvent from '@testing-library/user-event'
test('renders FormIUMK2 element', async() => {
test('renders FormIUMK2 element', async () => {
const store = makeTestStore(fixtureSet)
testRender(<FormIUMK />, {store})
......
import React from 'react'
import PropTypes from 'prop-types'
import {getEmail, getPhoneNumber} from '../../store/auth/authSlice'
import {useSelector} from 'react-redux'
const FormIUMK3 = ({data}) => {
const email = useSelector(getEmail)
const phoneNumber = useSelector(getPhoneNumber)
const urutan = [
'nama',
'email',
'no_telepon',
'alamat',
'barangJasa',
'status',
'karyawan',
'kbli',
'paket',
'waktu',
......@@ -15,16 +22,25 @@ const FormIUMK3 = ({data}) => {
]
const label = [
'Nama atau Calon Nama PT',
'Email',
'Nomor Telepon',
'Alamat',
'Barang yang dijual/Jasa yang ditawarkan',
'Status Entitas',
'Jumlah Karyawan',
'Kode KBLI',
'Paket',
'Waktu Pengerjaan',
'Harga',
'Catatan',
]
const konstan = {paket: 'Izin UMK', waktu: '19 Hari', harga: 'Rp8,500,000'}
const konstan = {
paket: 'Izin UMK',
waktu: '19 Hari',
harga: 'Rp8,500,000',
email: email,
no_telepon: phoneNumber,
}
data = {...data, ...konstan}
......@@ -40,9 +56,9 @@ const FormIUMK3 = ({data}) => {
{urutan[index] == 'catatan' ? (
<p
className="md\:font-Lato"
data-testid={`form-pt-3-input-${value}`}
data-testid={`form-iumk-3-input-${value}`}
>
{data[value]}
{data[value] && data[value] != null ? data[value] : '-'}
</p>
) : (
''
......@@ -53,8 +69,11 @@ const FormIUMK3 = ({data}) => {
''
) : (
<div className="flex justify-start lg:justify-end xl:justify-end 2xl:justify-end text-left lg:text-right xl:text-right 2xl:text-right pb-3">
<p className="heading-3" data-testid={`form-pt-3-input-${value}`}>
{data[value]}
<p
className="heading-3"
data-testid={`form-iumk-3-input-${value}`}
>
{data[value] && data[value] != null ? data[value] : '-'}
</p>
</div>
)}
......
import {screen, render} from '@testing-library/react'
import {screen} from '@testing-library/react'
import FormIUMK3 from './FormIUMK3'
import {testRender, makeTestStore} from '../../testUtils'
test('renders FormIUMK3 Element', () => {
render(<FormIUMK3 />)
const store = makeTestStore()
testRender(<FormIUMK3 />, {store})
expect(screen.getByTestId('form-iumk-3')).toBeInTheDocument()
// Test label
......@@ -24,20 +26,14 @@ test('renders FormIUMK3 Element', () => {
// Test data yang diinput oleh user
expect(screen.getByTestId('form-iumk-3-input-nama')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-email')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-no-tlp')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-no_telepon')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-alamat')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-jasa')).toBeInTheDocument()
expect(
screen.getByTestId('form-iumk-3-input-status-entitas'),
).toBeInTheDocument()
expect(
screen.getByTestId('form-iumk-3-input-jumlah-karyawan'),
).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-kode-kbli')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-barangJasa')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-status')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-karyawan')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-kbli')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-paket')).toBeInTheDocument()
expect(
screen.getByTestId('form-iumk-3-input-waktu-pengerjaan'),
).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-waktu')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-harga')).toBeInTheDocument()
expect(screen.getByTestId('form-iumk-3-input-catatan')).toBeInTheDocument()
})
......@@ -5,15 +5,18 @@ export const authSlice = createSlice({
initialState: {
token: undefined,
email: undefined,
phone_number: undefined,
},
reducers: {
login: (state, action) => {
state.token = action.payload.token
state.email = action.payload.email
state.phone_number = action.payload.phone_number
},
logout: (state) => {
state.token = undefined
state.email = undefined
state.phone_number = undefined
},
},
})
......@@ -21,6 +24,7 @@ export const authSlice = createSlice({
export const {login, logout} = authSlice.actions
export const getEmail = (state) => state.auth.email
export const getPhoneNumber = (state) => state.auth.phone_number
export const isLoggedIn = (state) => {
if (state.auth.token) {
return true
......
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