From cafd4789988bda3415fb046e747f2d83dee8fecb Mon Sep 17 00:00:00 2001 From: Colin Seper Date: Sat, 26 Oct 2024 14:01:32 -0500 Subject: [PATCH] Add Step Time Digits Testing Added testing to ensure StepTimeDigits has the correct structure. Added testing to ensure initial values for target zones and step time are correctly rendered. --- frontend/src/StepTimeDigits.js | 14 ++--- frontend/src/__tests__/StepTimeDigits.test.js | 55 +++++++++++++++++++ 2 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 frontend/src/__tests__/StepTimeDigits.test.js diff --git a/frontend/src/StepTimeDigits.js b/frontend/src/StepTimeDigits.js index 7850b26..68930f4 100644 --- a/frontend/src/StepTimeDigits.js +++ b/frontend/src/StepTimeDigits.js @@ -3,17 +3,17 @@ import "./StepTimeDigits.css"; function StepTimeDigits({ stepTime }) { return (
-
-

Target Zones

+
+

Target Zones

    -
  • {stepTime.targetZones.left.min}-{stepTime.targetZones.left.max}
  • -
  • {stepTime.targetZones.right.min}-{stepTime.targetZones.right.max}
  • +
  • {stepTime.targetZones.left.min}-{stepTime.targetZones.left.max}
  • +
  • {stepTime.targetZones.right.min}-{stepTime.targetZones.right.max}
-
+
    -
  • {stepTime.left}
  • -
  • {stepTime.right}
  • +
  • {stepTime.left}
  • +
  • {stepTime.right}
diff --git a/frontend/src/__tests__/StepTimeDigits.test.js b/frontend/src/__tests__/StepTimeDigits.test.js new file mode 100644 index 0000000..518276f --- /dev/null +++ b/frontend/src/__tests__/StepTimeDigits.test.js @@ -0,0 +1,55 @@ +import { render, screen } from "@testing-library/react"; +import StepTimeDigits from "../StepTimeDigits"; + +describe("Step Time View Structure", () => { + const testStepTime = { + left: 0, + right: 0, + targetZones: { + left: {min: 0, max:0}, + right: {min: 0, max:0}, + }, + }; + + test("Target Zone Structure Correctly Rendered", () => { + render(); + expect(screen.getByTestId('target-zones-values')).toBeInTheDocument(); + expect(screen.getByTestId('target-zones-title')).toBeInTheDocument(); + expect(screen.getByTestId('target-zones-left')).toBeInTheDocument(); + expect(screen.getByTestId('target-zones-right')).toBeInTheDocument(); + }); + + test("Step Time Value Structure Correctly Rendered", () => { + render(); + expect(screen.getByTestId('current-step-time-values')).toBeInTheDocument(); + expect(screen.getByTestId('current-step-time-left')).toBeInTheDocument(); + expect(screen.getByTestId('current-step-time-right')).toBeInTheDocument(); + }); +}); + +describe("Step Time Data", () => { + let testStepTime; + + beforeEach(() => { + testStepTime = { + left: 12, + right: 27, + targetZones: { + left: {min: 5, max: 10}, + right: {min: 3, max: 20}, + }, + }; + }); + + test("Initial Target Zones correctly rendered", () => { + render(); + expect(screen.getByTestId('target-zones-left').textContent).toBe('5-10'); + expect(screen.getByTestId('target-zones-right').textContent).toBe('3-20'); + }); + + test("Initial Current Step Time Values correctly rendered", () => { + render(); + expect(screen.getByTestId('current-step-time-left').textContent).toBe('12'); + expect(screen.getByTestId('current-step-time-right').textContent).toBe('27'); + }); +}); \ No newline at end of file