feat: add testing library dependencies and implement component tests
This commit is contained in:
committed by
Loic Coenen (aider)
parent
826069e8dd
commit
46168a70a8
@@ -1,4 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { Lamp } from '../components/Lamp';
|
||||
import { LampLine } from '../components/LampLine';
|
||||
import { useCurrentTime } from '../hooks/useCurrentTime';
|
||||
import { dateToBerlin } from '../utils';
|
||||
@@ -10,6 +11,39 @@ interface BerlinClockProps {
|
||||
export function BerlinClock({ enabled }: BerlinClockProps) {
|
||||
const { currentTime } = useCurrentTime();
|
||||
const berlin = dateToBerlin(currentTime);
|
||||
// Will render four LampLine components
|
||||
return null;
|
||||
|
||||
if (!enabled) return null;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{/* Seconds lamp */}
|
||||
<div data-testid="seconds-lamp">
|
||||
{berlin.secondsRow.length > 0 && (
|
||||
<span data-testid="lamp-0" aria-label={berlin.secondsRow[0]}>
|
||||
{/* optional visual */}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Five hours row */}
|
||||
<div data-testid="five-hours-row">
|
||||
<LampLine states={berlin.fiveHours} />
|
||||
</div>
|
||||
|
||||
{/* Single hours row */}
|
||||
<div data-testid="single-hours-row">
|
||||
<LampLine states={berlin.oneHour} />
|
||||
</div>
|
||||
|
||||
{/* Five minutes row */}
|
||||
<div data-testid="five-minutes-row">
|
||||
<LampLine states={berlin.fiveMinutes} />
|
||||
</div>
|
||||
|
||||
{/* Single minutes row */}
|
||||
<div data-testid="single-minutes-row">
|
||||
<LampLine states={berlin.oneMinute} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user