Adrià Vilanova Martínez | f19ea43 | 2024-01-23 20:20:52 +0100 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 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 () => { |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 15 | const textFiled = { |
| 16 | oneLineSummary: '', |
| 17 | stepsToReproduce: '', |
| 18 | describeProblem: '', |
| 19 | }; |
| 20 | const {container} = render(<DetailsStep textValues={textFiled} setIsRegression={() => {}}/>); |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 21 | |
| 22 | // this is checking for the first question |
| 23 | const input = container.querySelector('input'); |
| 24 | assert.isNotNull(input) |
| 25 | |
| 26 | // this is checking for the rest |
| 27 | const count = document.querySelectorAll('textarea').length; |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 28 | assert.equal(count, 4) |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 29 | }); |
| 30 | |
| 31 | it('renders category in title', async () => { |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 32 | const textFiled = { |
| 33 | oneLineSummary: '', |
| 34 | stepsToReproduce: '', |
| 35 | describeProblem: '', |
| 36 | }; |
| 37 | |
| 38 | const {container} = render(<DetailsStep category='UI' textValues={textFiled} setIsRegression={() => {}}/>); |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 39 | |
| 40 | // this is checking the title contains our category |
| 41 | const title = container.querySelector('h2'); |
| 42 | assert.include(title?.innerText, 'Details for problems with UI'); |
| 43 | }); |
| 44 | |
Adrià Vilanova Martínez | ac4a644 | 2022-05-15 19:05:13 +0200 | [diff] [blame] | 45 | }); |