test: add initial test files and component stubs
This commit is contained in:
committed by
Loic Coenen (aider)
parent
5a6de57a91
commit
826069e8dd
11
src/__tests__/BerlinClock.test.tsx
Normal file
11
src/__tests__/BerlinClock.test.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { BerlinClock } from '../containers/BerlinClock';
|
||||
|
||||
describe('BerlinClock', () => {
|
||||
it('renders when enabled', () => {
|
||||
render(<BerlinClock enabled={true} />);
|
||||
});
|
||||
it('does not render when disabled', () => {
|
||||
render(<BerlinClock enabled={false} />);
|
||||
});
|
||||
});
|
||||
8
src/__tests__/DigitalClock.test.tsx
Normal file
8
src/__tests__/DigitalClock.test.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { DigitalClock } from '../containers/DigitalClock';
|
||||
|
||||
describe('DigitalClock', () => {
|
||||
it('renders when enabled', () => {
|
||||
render(<DigitalClock enabled={true} />);
|
||||
});
|
||||
});
|
||||
9
src/__tests__/Lamp.test.tsx
Normal file
9
src/__tests__/Lamp.test.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { Lamp } from '../components/Lamp';
|
||||
import { LampState } from '../types';
|
||||
|
||||
describe('Lamp', () => {
|
||||
it('renders without crashing', () => {
|
||||
render(<Lamp state={LampState.Y} />);
|
||||
});
|
||||
});
|
||||
11
src/__tests__/LampLine.test.tsx
Normal file
11
src/__tests__/LampLine.test.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { LampLine } from '../components/LampLine';
|
||||
import { LampState } from '../types';
|
||||
|
||||
describe('LampLine', () => {
|
||||
it('renders correct number of lamps', () => {
|
||||
const states = [LampState.Y, LampState.R, LampState.O];
|
||||
render(<LampLine states={states} />);
|
||||
// TODO: assert number of child lamps
|
||||
});
|
||||
});
|
||||
13
src/__tests__/TimeConverter.test.tsx
Normal file
13
src/__tests__/TimeConverter.test.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import { TimeConverter } from '../containers/TimeConverter';
|
||||
|
||||
describe('TimeConverter', () => {
|
||||
it('renders the toggle checkbox', () => {
|
||||
render(<TimeConverter />);
|
||||
expect(screen.getByRole('checkbox')).toBeInTheDocument();
|
||||
});
|
||||
it('disables clocks when checkbox is checked', () => {
|
||||
render(<TimeConverter />);
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
10
src/__tests__/types.test.ts
Normal file
10
src/__tests__/types.test.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { LampState, BerlinClock } from '../types';
|
||||
|
||||
describe('Types', () => {
|
||||
it('LampState has correct values', () => {
|
||||
expect(LampState.Y).toBe('Y');
|
||||
expect(LampState.R).toBe('R');
|
||||
expect(LampState.O).toBe('O');
|
||||
expect(LampState.N).toBe('N');
|
||||
});
|
||||
});
|
||||
10
src/__tests__/useCurrentTime.test.ts
Normal file
10
src/__tests__/useCurrentTime.test.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { renderHook, act } from '@testing-library/react';
|
||||
import { useCurrentTime } from '../hooks/useCurrentTime';
|
||||
|
||||
describe('useCurrentTime', () => {
|
||||
it('returns a date and setter', () => {
|
||||
const { result } = renderHook(() => useCurrentTime());
|
||||
expect(result.current.currentTime).toBeInstanceOf(Date);
|
||||
expect(typeof result.current.setCurrentTime).toBe('function');
|
||||
});
|
||||
});
|
||||
16
src/__tests__/utils.test.ts
Normal file
16
src/__tests__/utils.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { dateToDigital, digitalToDate, dateToBerlin, berlinToDate } from '../utils';
|
||||
|
||||
describe('Utils', () => {
|
||||
it('dateToDigital returns correct format', () => {
|
||||
// TODO
|
||||
});
|
||||
it('digitalToDate returns a Date', () => {
|
||||
// TODO
|
||||
});
|
||||
it('dateToBerlin returns a BerlinClock', () => {
|
||||
// TODO
|
||||
});
|
||||
it('berlinToDate returns a Date', () => {
|
||||
// TODO
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user