Skip to content

Commit

Permalink
Fix eslint complaints about use state.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-1squared committed Sep 27, 2023
1 parent 9bde7e7 commit aaaea0b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion new/src/components/Scenarios/Scenario.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test("Scenario displays steps", async () => {
expect(textElement).toBeTruthy();
});

test("Scenario capitalizes title ", async () => {
test("Scenario capitalizes title", async () => {
let expanded = true;
const setExpanded = (value: boolean) => {
expanded = value;
Expand Down
22 changes: 13 additions & 9 deletions new/src/components/Scenarios/ScenarioClass.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { ScenarioModel } from "../../reportModel";
import { Scenario } from "./Scenario";
import { useState } from "react";
import {ScenarioModel} from "../../reportModel";
import {Scenario} from "./Scenario";
import {useState} from "react";

export function ScenarioClass(props: { scenarios: ScenarioModel[] }) {
const accordionExpansion: Map<
string,
{ expanded: boolean; setExpanded: (expanded: boolean) => void }
> = new Map();
props.scenarios.forEach(scenario => {
const [expanded, setExpanded] = useState(false);
accordionExpansion.set(scenario.testMethodName, {
expanded: expanded,
setExpanded: setExpanded
const [expanded, setExpanded] = useState(props.scenarios.map(__ => false));
for (let i = 0; i < props.scenarios.length; i++) {
accordionExpansion.set(props.scenarios[i].testMethodName, {
expanded: expanded[i],
setExpanded: (value) => {
const newExpanded = expanded;
newExpanded[i] = value;
setExpanded(newExpanded)
}
});
});
}
return (
<div>
{props.scenarios.map(scenario => (
Expand Down

0 comments on commit aaaea0b

Please sign in to comment.