/
test-2.tsx
32 lines (24 loc) · 849 Bytes
/
test-2.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
import React from 'react';
import { render, cleanup } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import { CardProvider, initialState } from '../../../../services/CardContext';
import Answer from './index';
afterEach(cleanup);
const renderAnswer = (visible?: boolean) => render(
<CardProvider>
<Answer visible={visible !== undefined ? visible : true}/>
</CardProvider>
);
it('renders without crashing', () => {
renderAnswer();
});
describe('when visible, it shows the answer', () => {
//has the div that will show the answer
it('has the answer div', () => {
const { getByTestId } = renderAnswer();
const answerDiv = getByTestId('answer')
expect(answerDiv).toBeInTheDocument();
});
// shows the right answer
// has a header with 'Answer'
});