adding api unit tests
This commit is contained in:
@@ -33,7 +33,7 @@ const LogForm = () => {
|
||||
`api/logs/${logbookContext.state.selectedLogId}`
|
||||
);
|
||||
const log = response.data;
|
||||
console.log(log)
|
||||
|
||||
reset(log);
|
||||
} catch (error) {
|
||||
const axiosError = error as AxiosError;
|
||||
@@ -53,11 +53,16 @@ const LogForm = () => {
|
||||
if (pilots && FormMode.ADD) {
|
||||
const newPilotsOptions = pilots.map((pilot) => {
|
||||
return {
|
||||
key: pilot.id,
|
||||
label: pilot.name,
|
||||
value: pilot.id,
|
||||
};
|
||||
});
|
||||
|
||||
newPilotsOptions.unshift({
|
||||
label: '',
|
||||
value: '',
|
||||
})
|
||||
|
||||
dispatch({ type: 'SET_PILOT_OPTIONS', payload: newPilotsOptions });
|
||||
}
|
||||
}, [pilots]);
|
||||
@@ -80,9 +85,9 @@ const LogForm = () => {
|
||||
onChange={onChange}
|
||||
value={[value]}
|
||||
>
|
||||
{state.pilotOptions?.map((pilotOption: { key: string; label: string, }) => {
|
||||
{state.pilotOptions?.map((pilotOption: { label: string, value: string; }) => {
|
||||
return (
|
||||
<option key={pilotOption.key}>{pilotOption.label}</option>
|
||||
<option value={pilotOption.value}>{pilotOption.label}</option>
|
||||
)
|
||||
})}
|
||||
</select>
|
||||
|
||||
@@ -4,6 +4,6 @@ export interface LogFormState {
|
||||
alert: Alert | undefined;
|
||||
isDisabled: boolean;
|
||||
isLoading: boolean;
|
||||
pilotOptions: { key: string; label: string; }[];
|
||||
pilotOptions: { label: string; value: string; }[];
|
||||
selectedPilotName: string;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ type Action =
|
||||
| { type: 'SET_ALERT'; payload: Alert | undefined }
|
||||
| { type: 'SET_IS_DISABLED'; payload: boolean }
|
||||
| { type: 'SET_IS_LOADING'; payload: boolean }
|
||||
| { type: 'SET_PILOT_OPTIONS'; payload: { key: string, label: string; }[] }
|
||||
| { type: 'SET_PILOT_OPTIONS'; payload: { label: string; value: string }[] }
|
||||
| { type: 'SET_SELECTED_PILOT_NAME'; payload: string };
|
||||
|
||||
export const initialState: LogFormState = {
|
||||
|
||||
Reference in New Issue
Block a user