diff --git a/.changeset/purple-items-turn.md b/.changeset/purple-items-turn.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/purple-items-turn.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/config/test/custom-matchers.ts b/config/test/custom-matchers.ts index 383384384f..74ebb6eaa3 100644 --- a/config/test/custom-matchers.ts +++ b/config/test/custom-matchers.ts @@ -112,10 +112,7 @@ expect.extend({ }; } - // TODO: Are we sure this is right? I wonder if it should be - // score.earned === score.total - // (in multi-widget questions, you can get some right and some wrong) - if (score.earned !== 0) { + if (score.earned >= score.total) { return { pass: false, message: () => `Problem was answered correctly.`, diff --git a/packages/perseus/src/widgets/image/image.test.ts b/packages/perseus/src/widgets/image/image.test.ts index 1f16bd040f..dfd369056a 100644 --- a/packages/perseus/src/widgets/image/image.test.ts +++ b/packages/perseus/src/widgets/image/image.test.ts @@ -5,6 +5,7 @@ import { } from "@khanacademy/perseus-core"; import {act, screen, within} from "@testing-library/react"; import {userEvent as userEventLib} from "@testing-library/user-event"; +import invariant from "tiny-invariant"; import * as Dependencies from "../../dependencies"; import {getFeatureFlags} from "../../testing/feature-flags-util"; @@ -56,7 +57,7 @@ describe.each([[true], [false]])("image widget - isMobile(%j)", (isMobile) => { expect(container).toMatchSnapshot("first render"); }); - it("should be unanswerable", () => { + it("should score zero points", () => { // Arrange // Act @@ -66,8 +67,13 @@ describe.each([[true], [false]])("image widget - isMobile(%j)", (isMobile) => { renderer.getUserInputMap(), ); + invariant( + score.type === "points", + `score.type should be "points", but was ${score.type}`, + ); + // Assert - expect(score).toHaveBeenAnsweredIncorrectly(); + expect(score.earned).toBe(0); }); it("should not render empty image", () => { diff --git a/packages/perseus/src/widgets/interaction/interaction.test.ts b/packages/perseus/src/widgets/interaction/interaction.test.ts index 142d6cb01b..f9e2481b9e 100644 --- a/packages/perseus/src/widgets/interaction/interaction.test.ts +++ b/packages/perseus/src/widgets/interaction/interaction.test.ts @@ -1,3 +1,5 @@ +import invariant from "tiny-invariant"; + import * as Dependencies from "../../dependencies"; import {testDependencies} from "../../testing/test-dependencies"; import {waitForInitialGraphieRender} from "../../testing/wait"; @@ -25,7 +27,7 @@ describe("interaction widget", () => { expect(container).toMatchSnapshot(); }); - it("should be unanswerable", async () => { + it("should score zero points", async () => { // Arrange const {renderer} = renderQuestion(question1); await waitForInitialGraphieRender(); @@ -36,10 +38,13 @@ describe("interaction widget", () => { renderer.getUserInputMap(), ); + invariant( + score.type === "points", + `score.type should be "points", but was ${score.type}`, + ); + // Assert - // Note that this widget can never be answered correctly, no matter - // what state its in. - expect(score).toHaveBeenAnsweredIncorrectly(); + expect(score.earned).toBe(0); }); it("renders movable point elements with blank constraintXMin, constraintXMax, etc.", async () => {