Skip to content

Commit

Permalink
Covered ScenarioCase with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Schüler committed Jun 14, 2024
1 parent 25fad18 commit 10afcae
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
26 changes: 26 additions & 0 deletions new/src/components/Scenarios/__test__/ScenarioCase.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { render, screen } from "@testing-library/react";
import { ScenarioCase } from "../ScenarioCase";
import { createScenarioCaseModel, createStepModel, createWord } from "./scenarioTestData";

describe("ScenarioCase", () => {
it("should display class name", () => {
const className = "name.of.my.class";
render(<ScenarioCase className={className} scenarioCase={createScenarioCaseModel()} />);

expect(screen.getByText(className)).toBeInTheDocument();
});

it("should display all scenario steps", () => {
const singleWordScenarioDescriptions = ["marine", "debug", "grind", "trivial", "timetable"];

const steps = singleWordScenarioDescriptions.map(description =>
createStepModel({ words: [createWord({ value: description })] })
);

render(<ScenarioCase className={""} scenarioCase={createScenarioCaseModel({ steps })} />);

singleWordScenarioDescriptions.forEach(description => {
expect(screen.getByText(description)).toBeVisible();
});
});
});
26 changes: 20 additions & 6 deletions new/src/components/Scenarios/__test__/scenarioTestData.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {StepModel, Word} from "../../../reportModel";
import { ScenarioCaseModel, StepModel, Word } from "../../../reportModel";

export function createWord(props?: Partial<Word>): Word {
return {
value: props?.value ?? "word value",
isIntroWord: props?.isIntroWord,
argumentInfo: props?.argumentInfo,
}
argumentInfo: props?.argumentInfo
};
}

export function createStepModel(props?: Partial<StepModel>): StepModel {
Expand All @@ -20,6 +20,20 @@ export function createStepModel(props?: Partial<StepModel>): StepModel {
extendedDescription: props?.extendedDescription,
attachments: props?.attachments,
isSectionTitle: props?.isSectionTitle,
comment: props?.comment,
}
}
comment: props?.comment
};
}

export function createScenarioCaseModel(props?: Partial<ScenarioCaseModel>): ScenarioCaseModel {
return {
caseNr: props?.caseNr ?? 0,
steps: props?.steps ?? [],
explicitArguments: props?.explicitArguments ?? [],
derivedArguments: props?.derivedArguments ?? [],
status: props?.status ?? "SUCCESS",
errorMessage: props?.errorMessage,
stackTrace: props?.stackTrace,
durationInNanos: props?.durationInNanos ?? 0,
description: props?.description
};
}

0 comments on commit 10afcae

Please sign in to comment.