Skip to content

Commit 1c6d859

Browse files
authored
fix(test): Clock face unmount, cleanup (#296)
1 parent e06414f commit 1c6d859

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/ClockFace.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { ClockHands } from '@/ClockHands';
22
import { Graduations } from '@/Graduations';
33
import { getTestId } from '@/utilities';
44

5+
export const clockFaceId = 'clock-face';
6+
57
export const ClockFace = () => (
68
<div
79
class="grid h-screen place-content-center dark:bg-zinc-800"
8-
data-testid={getTestId('clock-face')}
10+
data-testid={getTestId(clockFaceId)}
911
>
1012
<svg class="h-[95vmin]" viewBox="0 0 200 200">
1113
<image class="size-1/6 translate-5/12" href="logo.svg" />

test/ClockFace.test.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { describe, expect, test } from 'vitest';
22
import { render } from 'vitest-browser-solid';
33

4-
import { ClockFace } from '@/ClockFace';
4+
import { ClockFace, clockFaceId } from '@/ClockFace';
55

66
describe('<ClockFace />', () => {
77
test('renders clock face', () => {
88
const screen = render(() => <ClockFace />);
9-
expect(screen.getByTestId('clock-face')).toBeInTheDocument();
9+
expect(screen.getByTestId(clockFaceId)).toBeInTheDocument();
1010
});
1111
test('unmount clock face', () => {
12-
const { unmount } = render(() => <ClockFace />);
13-
unmount();
12+
const screen = render(() => <ClockFace />);
13+
screen.unmount();
14+
expect(screen.getByTestId(clockFaceId)).not.toBeInTheDocument();
1415
});
1516
});

0 commit comments

Comments
 (0)