Skip to content

Commit

Permalink
respond to Jeremys feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
handeyeco committed Nov 26, 2024
1 parent febaac0 commit bbcfde0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
15 changes: 10 additions & 5 deletions packages/perseus/src/widgets/expression/expression.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import {
expressionItemWithLabels,
} from "./expression.testdata";

import type {PerseusItem} from "../../perseus-types";
import type {
PerseusExpressionWidgetOptions,
PerseusItem,
} from "../../perseus-types";
import type {UserEvent} from "@testing-library/user-event";

const renderAndAnswer = async (
Expand Down Expand Up @@ -535,9 +538,7 @@ describe("Expression Widget", function () {
value: "42",
};

const result = ExpressionWidgetExport.propUpgrades["1"](v0props);

expect(result).toEqual({
const expected: PerseusExpressionWidgetOptions = {
times: false,
buttonSets: ["basic"],
functions: [],
Expand All @@ -549,7 +550,11 @@ describe("Expression Widget", function () {
value: "42",
},
],
});
};

const result = ExpressionWidgetExport.propUpgrades["1"](v0props);

expect(result).toEqual(expected);
});
});
});
12 changes: 8 additions & 4 deletions packages/perseus/src/widgets/measurer/measurer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import MeasurerWidgetExport from "./measurer";

import type {PerseusMeasurerWidgetOptions} from "../../perseus-types";

describe("measurer", () => {
describe("propUpgrades", () => {
it("can upgrade from v0 to v1", () => {
Expand All @@ -17,9 +19,7 @@ describe("measurer", () => {
static: false,
};

const result = MeasurerWidgetExport.propUpgrades["1"](v0props);

expect(result).toEqual({
const expected: PerseusMeasurerWidgetOptions = {
image: {
url: "url",
top: 42,
Expand All @@ -33,7 +33,11 @@ describe("measurer", () => {
rulerLength: 4,
box: [4, 4],
static: false,
});
};

const result = MeasurerWidgetExport.propUpgrades["1"](v0props);

expect(result).toEqual(expected);
});
});
});
15 changes: 10 additions & 5 deletions packages/perseus/src/widgets/radio/__tests__/radio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import {
shuffledNoneQuestion,
} from "./radio.testdata";

import type {PerseusRenderer} from "../../../perseus-types";
import type {
PerseusRadioWidgetOptions,
PerseusRenderer,
} from "../../../perseus-types";
import type {APIOptions} from "../../../types";
import type {PerseusRadioUserInput} from "../../../validation.types";
import type {UserEvent} from "@testing-library/user-event";
Expand Down Expand Up @@ -992,12 +995,14 @@ describe("propsUpgrade", () => {
choices: [{content: "Choice 1"}, {content: "Choice 2"}],
};

const result = RadioWidgetExport.propUpgrades["1"](v0props);

expect(result).toEqual({
const expected: PerseusRadioWidgetOptions = {
choices: [{content: "Choice 1"}, {content: "Choice 2"}],
hasNoneOfTheAbove: false,
});
};

const result = RadioWidgetExport.propUpgrades["1"](v0props);

expect(result).toEqual(expected);
});

it("throws from noneOfTheAbove", () => {
Expand Down

0 comments on commit bbcfde0

Please sign in to comment.