Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/purple-items-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
5 changes: 1 addition & 4 deletions config/test/custom-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand Down
10 changes: 8 additions & 2 deletions packages/perseus/src/widgets/image/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand All @@ -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", () => {
Expand Down
13 changes: 9 additions & 4 deletions packages/perseus/src/widgets/interaction/interaction.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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();
Expand All @@ -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 () => {
Expand Down
Loading