Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | import React from 'react'; |
| 6 | import {render, cleanup} from '@testing-library/react'; |
| 7 | import {assert} from 'chai'; |
| 8 | |
| 9 | import DetailsStep from './DetailsStep.tsx'; |
| 10 | |
| 11 | describe('DetailsStep', () => { |
| 12 | afterEach(cleanup); |
| 13 | |
| 14 | it('renders', async () => { |
| 15 | const {container} = render(<DetailsStep />); |
| 16 | |
| 17 | // this is checking for the first question |
| 18 | const input = container.querySelector('input'); |
| 19 | assert.isNotNull(input) |
| 20 | |
| 21 | // this is checking for the rest |
| 22 | const count = document.querySelectorAll('textarea').length; |
| 23 | assert.equal(count, 3) |
| 24 | }); |
| 25 | |
| 26 | it('renders category in title', async () => { |
| 27 | const {container} = render(<DetailsStep category='UI'/>); |
| 28 | |
| 29 | // this is checking the title contains our category |
| 30 | const title = container.querySelector('h2'); |
| 31 | assert.include(title?.innerText, 'Details for problems with UI'); |
| 32 | }); |
| 33 | |
| 34 | }); |