-
Notifications
You must be signed in to change notification settings - Fork 1
/
Hooks.test.tsx
34 lines (25 loc) · 905 Bytes
/
Hooks.test.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react'
import { render, waitForElement, fireEvent } from '@testing-library/react';
import Hooks from '../Hooks';
describe('Hooks Tests', () => {
const { getByTestId, getByText } = render(<Hooks/>);
it('should render Hooks Component', async () => {
const spanTextNode = await waitForElement(() =>
getByTestId('counter-head'),
);
expect(spanTextNode.textContent).toBe('Hooks Counter');
});
it('should check count value on first render', async () => {
const spanTextNode = await waitForElement(() =>
getByTestId('counter-value'),
);
expect(spanTextNode.textContent).toBe('0');
});
it('should click and assert counter value', async () => {
fireEvent.click(getByText('Count'));
const spanTextNode = await waitForElement(() =>
getByTestId('counter-value'),
);
expect(spanTextNode.textContent).toBe('1');
});
});