Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nishasy committed Mar 13, 2024
1 parent a8d4e30 commit 29da3de
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions packages/perseus/src/widgets/__tests__/interactive-graph.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {describe, beforeEach, it} from "@jest/globals";
import {color} from "@khanacademy/wonder-blocks-tokens";
import {waitFor} from "@testing-library/react";
import {userEvent as userEventLib} from "@testing-library/user-event";

Expand All @@ -9,6 +10,7 @@ import {ApiOptions} from "../../perseus-api";
import {
questionsAndAnswers,
segmentQuestion,
segmentWithLockedPointsQuestion,
segmentQuestionDefaultCorrect,
} from "../__testdata__/interactive-graph.testdata";

Expand Down Expand Up @@ -178,3 +180,43 @@ describe("segment graph", () => {
});
});
});

describe("locked layer", () => {
const apiOptions = {flags: {mafs: {segment: true}}};
it("should render locked points", async () => {
// Arrange
const {container} = renderQuestion(
segmentWithLockedPointsQuestion,
apiOptions,
);

// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
const points = container.querySelectorAll(
// Filter out the interactive points' circles
"circle:not(.mafs-movable-point):not(.mafs-movable-point-hitbox):not(.mafs-movable-point-focus):not(.mafs-movable-point-ring):not(.mafs-movable-point-point)",
);

// Act

// Assert
expect(points).toHaveLength(2);
});

test("should render locked points with styles", async () => {
// Arrange
const {container} = renderQuestion(
segmentWithLockedPointsQuestion,
apiOptions,
);

// Act
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
const points = container.querySelectorAll(
"circle:not(.mafs-movable-point):not(.mafs-movable-point-hitbox):not(.mafs-movable-point-focus):not(.mafs-movable-point-ring):not(.mafs-movable-point-point)",
);

// Assert
expect(points[0]).toHaveStyle({fill: color.red, stroke: color.red});
expect(points[1]).toHaveStyle({fill: color.red, stroke: color.red});
});
});

0 comments on commit 29da3de

Please sign in to comment.