All checks were successful
Deploy to Staging / Build Images (pull_request) Successful in 3m22s
Deploy to Staging / Deploy to Staging (pull_request) Successful in 51s
Deploy to Staging / Verify Staging (pull_request) Successful in 8s
Deploy to Staging / Notify Staging Ready (pull_request) Successful in 7s
Deploy to Staging / Notify Staging Failure (pull_request) Has been skipped
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { render, screen, fireEvent } from '@testing-library/react';
|
|
import { ActionBar } from '../ActionBar';
|
|
|
|
describe('ActionBar', () => {
|
|
it('renders both buttons with correct text', () => {
|
|
const onAddVehicle = jest.fn();
|
|
const onLogFuel = jest.fn();
|
|
|
|
render(<ActionBar onAddVehicle={onAddVehicle} onLogFuel={onLogFuel} />);
|
|
|
|
expect(screen.getByText('Add Vehicle')).toBeInTheDocument();
|
|
expect(screen.getByText('Log Fuel')).toBeInTheDocument();
|
|
});
|
|
|
|
it('calls onAddVehicle when Add Vehicle button clicked', () => {
|
|
const onAddVehicle = jest.fn();
|
|
const onLogFuel = jest.fn();
|
|
|
|
render(<ActionBar onAddVehicle={onAddVehicle} onLogFuel={onLogFuel} />);
|
|
|
|
const addVehicleButton = screen.getByText('Add Vehicle');
|
|
fireEvent.click(addVehicleButton);
|
|
|
|
expect(onAddVehicle).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it('calls onLogFuel when Log Fuel button clicked', () => {
|
|
const onAddVehicle = jest.fn();
|
|
const onLogFuel = jest.fn();
|
|
|
|
render(<ActionBar onAddVehicle={onAddVehicle} onLogFuel={onLogFuel} />);
|
|
|
|
const logFuelButton = screen.getByText('Log Fuel');
|
|
fireEvent.click(logFuelButton);
|
|
|
|
expect(onLogFuel).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|