mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-08 04:06:18 -04:00
Add race control visuals and driver names in laps view
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { LapsView } from '../components/LapsView'
|
||||
import type { Lap } from '../types'
|
||||
import type { Driver, Lap } from '../types'
|
||||
|
||||
const laps: Lap[] = [
|
||||
{
|
||||
@@ -33,15 +33,46 @@ const laps: Lap[] = [
|
||||
},
|
||||
]
|
||||
|
||||
const drivers: Driver[] = [
|
||||
{
|
||||
driver_number: 44,
|
||||
name_acronym: 'HAM',
|
||||
full_name: 'Lewis Hamilton',
|
||||
first_name: 'Lewis',
|
||||
last_name: 'Hamilton',
|
||||
team_name: 'Ferrari',
|
||||
team_colour: 'E80020',
|
||||
headshot_url: '',
|
||||
broadcast_name: 'L HAMILTON',
|
||||
session_key: 9472,
|
||||
meeting_key: 1229,
|
||||
},
|
||||
{
|
||||
driver_number: 1,
|
||||
name_acronym: 'VER',
|
||||
full_name: 'Max Verstappen',
|
||||
first_name: 'Max',
|
||||
last_name: 'Verstappen',
|
||||
team_name: 'Red Bull Racing',
|
||||
team_colour: '3671C6',
|
||||
headshot_url: '',
|
||||
broadcast_name: 'M VERSTAPPEN',
|
||||
session_key: 9472,
|
||||
meeting_key: 1229,
|
||||
},
|
||||
]
|
||||
|
||||
describe('LapsView', () => {
|
||||
it('renders compact best-lap rows by driver', () => {
|
||||
render(<LapsView laps={laps} />)
|
||||
render(<LapsView laps={laps} drivers={drivers} />)
|
||||
|
||||
expect(screen.getByTestId('laps-view')).toBeInTheDocument()
|
||||
expect(screen.getByText('#1')).toBeInTheDocument()
|
||||
expect(screen.getByText('#44')).toBeInTheDocument()
|
||||
expect(screen.getByText('Max Verstappen')).toBeInTheDocument()
|
||||
expect(screen.getByText('Lewis Hamilton')).toBeInTheDocument()
|
||||
expect(screen.getByText('1:12.100')).toBeInTheDocument()
|
||||
expect(screen.getByText('FASTEST')).toBeInTheDocument()
|
||||
expect(screen.getByText('+3.100')).toBeInTheDocument()
|
||||
expect(screen.queryByText('FASTEST')).not.toBeInTheDocument()
|
||||
expect(screen.getByText('Max Verstappen').closest('tr')).toHaveClass('lap-fastest-row')
|
||||
})
|
||||
|
||||
it('shows a missing-data state when no laps are present', () => {
|
||||
|
||||
Reference in New Issue
Block a user