blob: e53c3a920ed2d9d12265dea8febe8fba97ba1ae2 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001// 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
5import React from 'react';
6import {render, cleanup} from '@testing-library/react';
7import {assert} from 'chai';
8
9import DetailsStep from './DetailsStep.tsx';
10
11describe('DetailsStep', () => {
12 afterEach(cleanup);
13
14 it('renders', async () => {
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020015 const textFiled = {
16 oneLineSummary: '',
17 stepsToReproduce: '',
18 describeProblem: '',
19 };
20 const {container} = render(<DetailsStep textValues={textFiled} setIsRegression={() => {}}/>);
Copybara854996b2021-09-07 19:36:02 +000021
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ínezac4a6442022-05-15 19:05:13 +020028 assert.equal(count, 4)
Copybara854996b2021-09-07 19:36:02 +000029 });
30
31 it('renders category in title', async () => {
Adrià Vilanova Martínezac4a6442022-05-15 19:05:13 +020032 const textFiled = {
33 oneLineSummary: '',
34 stepsToReproduce: '',
35 describeProblem: '',
36 };
37
38 const {container} = render(<DetailsStep category='UI' textValues={textFiled} setIsRegression={() => {}}/>);
Copybara854996b2021-09-07 19:36:02 +000039
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ínezac4a6442022-05-15 19:05:13 +020045});