@khanacademy/perseus-editor 4.1.5 → 4.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +9 -6
- package/.babelrc.js +0 -8
- package/.eslintrc.js +0 -12
- package/CHANGELOG.md +0 -1155
- package/src/README.md +0 -7
- package/src/__stories__/editor-page.stories.tsx +0 -65
- package/src/__stories__/editor.stories.tsx +0 -134
- package/src/__stories__/item-editor.stories.tsx +0 -41
- package/src/__stories__/tex-error-view.stories.tsx +0 -26
- package/src/__testdata__/input-number.testdata.ts +0 -27
- package/src/__tests__/editor.test.tsx +0 -142
- package/src/__tests__/hint-editor.test.tsx +0 -83
- package/src/__tests__/i18n.test.ts +0 -501
- package/src/__tests__/integration.test.ts +0 -5
- package/src/__tests__/item-extras-editor.test.tsx +0 -85
- package/src/__tests__/traversal.test.ts +0 -377
- package/src/all-editors.test.ts +0 -16
- package/src/all-editors.ts +0 -83
- package/src/all-widgets.ts +0 -7
- package/src/article-editor.tsx +0 -438
- package/src/components/__stories__/blur-input.stories.tsx +0 -22
- package/src/components/__stories__/section-control-button.stories.tsx +0 -26
- package/src/components/__tests__/blur-input.test.tsx +0 -67
- package/src/components/blur-input.tsx +0 -69
- package/src/components/checkbox.tsx +0 -194
- package/src/components/device-framer.tsx +0 -90
- package/src/components/drag-target.tsx +0 -87
- package/src/components/dropdown-option.tsx +0 -311
- package/src/components/form-wrapped-text-field.tsx +0 -245
- package/src/components/graph-points-count-selector.tsx +0 -31
- package/src/components/graph-settings.tsx +0 -627
- package/src/components/graph-type-selector.tsx +0 -31
- package/src/components/hover-behavior.ts +0 -177
- package/src/components/json-editor.tsx +0 -121
- package/src/components/link.ts +0 -173
- package/src/components/section-control-button.tsx +0 -53
- package/src/components/segment-count-selector.tsx +0 -27
- package/src/components/simple-button.tsx +0 -85
- package/src/components/sortable.tsx +0 -187
- package/src/components/util.ts +0 -38
- package/src/components/viewport-resizer.tsx +0 -72
- package/src/components/widget-editor.tsx +0 -222
- package/src/components/widget-select.tsx +0 -48
- package/src/diffs/__stories__/perseus-diff-wrapper.tsx +0 -11
- package/src/diffs/__stories__/structured-item-diff.stories.tsx +0 -855
- package/src/diffs/__stories__/tags-diff.stories.tsx +0 -36
- package/src/diffs/__stories__/text-diff.stories.tsx +0 -35
- package/src/diffs/__tests__/split-diff.test.ts +0 -33
- package/src/diffs/__tests__/string-array-diff.test.ts +0 -73
- package/src/diffs/__tests__/structured-item-diff.test.ts +0 -433
- package/src/diffs/__tests__/widget-diff-performer.test.ts +0 -43
- package/src/diffs/article-diff.tsx +0 -69
- package/src/diffs/item-diff.tsx +0 -76
- package/src/diffs/renderer-diff.tsx +0 -137
- package/src/diffs/split-diff.ts +0 -31
- package/src/diffs/string-array-diff.ts +0 -74
- package/src/diffs/structured-item-diff.tsx +0 -275
- package/src/diffs/tags-diff.tsx +0 -49
- package/src/diffs/text-diff.tsx +0 -193
- package/src/diffs/widget-diff-performer.ts +0 -69
- package/src/diffs/widget-diff.tsx +0 -290
- package/src/editor-page.tsx +0 -325
- package/src/editor.tsx +0 -1099
- package/src/hint-editor.tsx +0 -469
- package/src/i18n.ts +0 -140
- package/src/iframe-content-renderer.tsx +0 -188
- package/src/index.ts +0 -30
- package/src/item-editor.tsx +0 -158
- package/src/item-extras-editor.tsx +0 -230
- package/src/katex-mhchem/index.js +0 -73
- package/src/katex-mhchem/parser.js +0 -2659
- package/src/multirenderer-editor.tsx +0 -1061
- package/src/stateful-article-editor.tsx +0 -173
- package/src/stateful-editor-page.tsx +0 -88
- package/src/styles/perseus-editor.less +0 -1321
- package/src/testing-widgets.ts +0 -11
- package/src/tex-error-view.tsx +0 -90
- package/src/util/points.test.ts +0 -24
- package/src/util/points.ts +0 -13
- package/src/util/register-all-widgets-and-editors-for-testing.test.ts +0 -17
- package/src/util/register-all-widgets-and-editors-for-testing.ts +0 -17
- package/src/version.ts +0 -10
- package/src/widgets/__stories__/categorizer-editor.stories.tsx +0 -24
- package/src/widgets/__stories__/definition-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/dropdown-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/explanation-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/expression-editor.stories.tsx +0 -122
- package/src/widgets/__stories__/image-editor.stories.tsx +0 -72
- package/src/widgets/__stories__/input-number-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/interaction-editor.stories.tsx +0 -37
- package/src/widgets/__stories__/label-image-editor.stories.tsx +0 -99
- package/src/widgets/__stories__/matcher-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/number-line-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/numeric-input-editor.stories.tsx +0 -18
- package/src/widgets/__stories__/radio-editor.stories.tsx +0 -116
- package/src/widgets/__stories__/sorter-editor.stories.tsx +0 -18
- package/src/widgets/__tests__/categorizer-editor.test.tsx +0 -51
- package/src/widgets/__tests__/definition-editor.test.tsx +0 -41
- package/src/widgets/__tests__/dropdown-editor.test.tsx +0 -57
- package/src/widgets/__tests__/explanation-editor.test.tsx +0 -59
- package/src/widgets/__tests__/expression-editor.test.tsx +0 -403
- package/src/widgets/__tests__/input-number-editor.test.tsx +0 -128
- package/src/widgets/__tests__/matcher-editor.test.tsx +0 -47
- package/src/widgets/__tests__/number-line-editor.test.tsx +0 -144
- package/src/widgets/__tests__/numeric-input-editor.test.tsx +0 -177
- package/src/widgets/__tests__/radio-editor.test.tsx +0 -118
- package/src/widgets/__tests__/sorter-editor.test.tsx +0 -55
- package/src/widgets/categorizer-editor.tsx +0 -104
- package/src/widgets/cs-program-editor.tsx +0 -256
- package/src/widgets/definition-editor.tsx +0 -77
- package/src/widgets/deprecated-standin-editor.tsx +0 -29
- package/src/widgets/dropdown-editor.tsx +0 -211
- package/src/widgets/example-graphie-widget-editor.tsx +0 -70
- package/src/widgets/example-graphie-widget.tsx +0 -172
- package/src/widgets/example-widget-editor.tsx +0 -62
- package/src/widgets/example-widget.tsx +0 -154
- package/src/widgets/explanation-editor.tsx +0 -92
- package/src/widgets/expression-editor.tsx +0 -557
- package/src/widgets/graded-group-editor.tsx +0 -161
- package/src/widgets/graded-group-set-editor.tsx +0 -104
- package/src/widgets/grapher-editor.tsx +0 -155
- package/src/widgets/group-editor.tsx +0 -83
- package/src/widgets/iframe-editor.tsx +0 -202
- package/src/widgets/image-editor.tsx +0 -367
- package/src/widgets/input-number-editor.tsx +0 -288
- package/src/widgets/interaction-editor/constraint-editor.tsx +0 -134
- package/src/widgets/interaction-editor/function-editor.tsx +0 -108
- package/src/widgets/interaction-editor/index.ts +0 -3
- package/src/widgets/interaction-editor/interaction-editor.tsx +0 -749
- package/src/widgets/interaction-editor/label-editor.tsx +0 -87
- package/src/widgets/interaction-editor/line-editor.tsx +0 -125
- package/src/widgets/interaction-editor/mathquill-input.tsx +0 -81
- package/src/widgets/interaction-editor/movable-line-editor.tsx +0 -121
- package/src/widgets/interaction-editor/movable-point-editor.tsx +0 -89
- package/src/widgets/interaction-editor/parametric-editor.tsx +0 -117
- package/src/widgets/interaction-editor/point-editor.tsx +0 -72
- package/src/widgets/interaction-editor/rectangle-editor.tsx +0 -96
- package/src/widgets/interactive-graph-editor.tsx +0 -571
- package/src/widgets/label-image/__stories__/answer-choices.stories.tsx +0 -82
- package/src/widgets/label-image/__stories__/behavior.stories.tsx +0 -31
- package/src/widgets/label-image/__stories__/marker.stories.tsx +0 -75
- package/src/widgets/label-image/__stories__/question-markers.stories.tsx +0 -107
- package/src/widgets/label-image/__stories__/select-image.stories.tsx +0 -59
- package/src/widgets/label-image/answer-choices.tsx +0 -231
- package/src/widgets/label-image/behavior.tsx +0 -122
- package/src/widgets/label-image/marker.tsx +0 -290
- package/src/widgets/label-image/question-markers.tsx +0 -176
- package/src/widgets/label-image/select-image.tsx +0 -81
- package/src/widgets/label-image-editor.tsx +0 -252
- package/src/widgets/lights-puzzle-editor.tsx +0 -278
- package/src/widgets/matcher-editor.tsx +0 -149
- package/src/widgets/matrix-editor.tsx +0 -156
- package/src/widgets/measurer-editor.tsx +0 -253
- package/src/widgets/molecule-editor.tsx +0 -64
- package/src/widgets/number-line-editor.tsx +0 -512
- package/src/widgets/numeric-input-editor.tsx +0 -536
- package/src/widgets/orderer-editor.tsx +0 -172
- package/src/widgets/passage-editor.tsx +0 -117
- package/src/widgets/passage-ref-editor.tsx +0 -80
- package/src/widgets/passage-ref-target-editor.tsx +0 -49
- package/src/widgets/plotter-editor.tsx +0 -542
- package/src/widgets/radio/editor.tsx +0 -398
- package/src/widgets/reaction-diagram-editor.tsx +0 -131
- package/src/widgets/sequence-editor.tsx +0 -205
- package/src/widgets/simple-markdown-tester-editor.tsx +0 -86
- package/src/widgets/simple-markdown-tester.tsx +0 -92
- package/src/widgets/simulator-editor.tsx +0 -146
- package/src/widgets/sorter-editor.tsx +0 -103
- package/src/widgets/table-editor.tsx +0 -164
- package/src/widgets/unit-editor.tsx +0 -299
- package/src/widgets/video-editor.tsx +0 -73
- package/tsconfig-build.json +0 -22
- package/tsconfig-build.tsbuildinfo +0 -1
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @khanacademy/ts-no-error-suppressions */
|
|
2
|
-
import {StyleSheet, css} from "aphrodite";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
|
|
5
|
-
import RadioEditor from "../radio/editor";
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
PerseusRadioWidgetOptions,
|
|
9
|
-
PerseusRenderer,
|
|
10
|
-
APIOptions,
|
|
11
|
-
} from "@khanacademy/perseus";
|
|
12
|
-
|
|
13
|
-
// TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
|
|
14
|
-
type Empty = Record<string, never>;
|
|
15
|
-
|
|
16
|
-
type StoryArgs = Record<any, any>;
|
|
17
|
-
|
|
18
|
-
type Story = {
|
|
19
|
-
title: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
title: "Perseus/Editor/Widgets/Radio Editor",
|
|
24
|
-
} as Story;
|
|
25
|
-
|
|
26
|
-
const styles = StyleSheet.create({
|
|
27
|
-
wrapper: {
|
|
28
|
-
// The maximum width of a widget in the editor.
|
|
29
|
-
width: 338,
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const question: PerseusRenderer = {
|
|
34
|
-
content:
|
|
35
|
-
"Which of the following values of $x$ satisfies the equation $\\sqrt{64}=x$ ?\n\n[[\u2603 radio 1]]\n\n",
|
|
36
|
-
images: {},
|
|
37
|
-
widgets: {
|
|
38
|
-
"radio 1": {
|
|
39
|
-
graded: true,
|
|
40
|
-
version: {
|
|
41
|
-
major: 1,
|
|
42
|
-
minor: 0,
|
|
43
|
-
},
|
|
44
|
-
static: false,
|
|
45
|
-
type: "radio",
|
|
46
|
-
options: {
|
|
47
|
-
displayCount: null,
|
|
48
|
-
onePerLine: false,
|
|
49
|
-
choices: [
|
|
50
|
-
{
|
|
51
|
-
content: "$-8$ and $8$",
|
|
52
|
-
correct: false,
|
|
53
|
-
clue: "The square root operation ($\\sqrt{\\phantom{x}}$) calculates *only* the positive square root when performed on a number, so $x$ is equal to *only* $8$.",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
content: "$-8$",
|
|
57
|
-
correct: false,
|
|
58
|
-
clue: "While $(-8)^2=64$, the square root operation ($\\sqrt{\\phantom{x}}$) calculates *only* the positive square root when performed on a number.",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
content: "$8$",
|
|
62
|
-
correct: true,
|
|
63
|
-
isNoneOfTheAbove: false,
|
|
64
|
-
clue: "$8$ is the positive square root of $64$.",
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
content: "No value of $x$ satisfies the equation.",
|
|
68
|
-
correct: false,
|
|
69
|
-
isNoneOfTheAbove: false,
|
|
70
|
-
clue: "$8$ satisfies the equation.",
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
countChoices: false,
|
|
74
|
-
hasNoneOfTheAbove: false,
|
|
75
|
-
multipleSelect: false,
|
|
76
|
-
randomize: false,
|
|
77
|
-
deselectEnabled: false,
|
|
78
|
-
},
|
|
79
|
-
alignment: "default",
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
class WithState extends React.Component<Empty, PerseusRadioWidgetOptions> {
|
|
85
|
-
// @ts-expect-error [FEI-5003] - TS2564 - Property '_widget' has no initializer and is not definitely assigned in the constructor.
|
|
86
|
-
_widget: RadioEditor;
|
|
87
|
-
|
|
88
|
-
//$FlowIgnore
|
|
89
|
-
// @ts-expect-error [FEI-5003] - TS2416 - Property 'state' in type 'WithState' is not assignable to the same property in base type 'Component<Empty, PerseusRadioWidgetOptions, any>'.
|
|
90
|
-
state = question.widgets["radio 1"];
|
|
91
|
-
|
|
92
|
-
apiOptions: APIOptions = Object.freeze({});
|
|
93
|
-
|
|
94
|
-
render(): React.ReactNode {
|
|
95
|
-
return (
|
|
96
|
-
<div className={css(styles.wrapper)}>
|
|
97
|
-
<RadioEditor
|
|
98
|
-
{...this.state}
|
|
99
|
-
apiOptions={this.apiOptions}
|
|
100
|
-
onChange={(props) => {
|
|
101
|
-
this.setState({
|
|
102
|
-
...this._widget.serialize(),
|
|
103
|
-
...props,
|
|
104
|
-
});
|
|
105
|
-
}}
|
|
106
|
-
// @ts-expect-error [FEI-5003] - TS2322 - Type 'RadioEditor | null' is not assignable to type 'RadioEditor'.
|
|
107
|
-
ref={(widget) => (this._widget = widget)}
|
|
108
|
-
/>
|
|
109
|
-
</div>
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
115
|
-
return <WithState />;
|
|
116
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {action} from "@storybook/addon-actions";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
|
|
4
|
-
import SorterEditor from "../sorter-editor";
|
|
5
|
-
|
|
6
|
-
type StoryArgs = Record<any, any>;
|
|
7
|
-
|
|
8
|
-
type Story = {
|
|
9
|
-
title: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export default {
|
|
13
|
-
title: "Perseus/Editor/Widgets/Sorter Editor",
|
|
14
|
-
} as Story;
|
|
15
|
-
|
|
16
|
-
export const Default = (args: StoryArgs): React.ReactElement => {
|
|
17
|
-
return <SorterEditor onChange={action("onChange")} />;
|
|
18
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import {ApiOptions, Dependencies} from "@khanacademy/perseus";
|
|
2
|
-
import {render, screen} from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
import "@testing-library/jest-dom";
|
|
7
|
-
|
|
8
|
-
import {testDependencies} from "../../../../../testing/test-dependencies";
|
|
9
|
-
import CategorizerEditor from "../categorizer-editor";
|
|
10
|
-
|
|
11
|
-
describe("categorizer-editor", () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.spyOn(Dependencies, "getDependencies").mockReturnValue(
|
|
14
|
-
testDependencies,
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should render", async () => {
|
|
19
|
-
render(
|
|
20
|
-
<CategorizerEditor
|
|
21
|
-
onChange={() => undefined}
|
|
22
|
-
apiOptions={ApiOptions.defaults}
|
|
23
|
-
/>,
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
expect(
|
|
27
|
-
await screen.findByText("Randomize item order"),
|
|
28
|
-
).toBeInTheDocument();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("should be possible to change randomize item order", async () => {
|
|
32
|
-
const onChangeMock = jest.fn();
|
|
33
|
-
|
|
34
|
-
render(
|
|
35
|
-
<CategorizerEditor
|
|
36
|
-
onChange={onChangeMock}
|
|
37
|
-
apiOptions={ApiOptions.defaults}
|
|
38
|
-
/>,
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
userEvent.click(
|
|
42
|
-
screen.getByRole("checkbox", {
|
|
43
|
-
name: "Randomize item order",
|
|
44
|
-
}),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
expect(onChangeMock).toBeCalledWith(
|
|
48
|
-
expect.objectContaining({randomizeItems: true}),
|
|
49
|
-
);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import {Dependencies} from "@khanacademy/perseus";
|
|
2
|
-
import {render, screen} from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
import "@testing-library/jest-dom";
|
|
7
|
-
|
|
8
|
-
import {testDependencies} from "../../../../../testing/test-dependencies";
|
|
9
|
-
import DefinitionEditor from "../definition-editor";
|
|
10
|
-
|
|
11
|
-
describe("definition-editor", () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.spyOn(Dependencies, "getDependencies").mockReturnValue(
|
|
14
|
-
testDependencies,
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should render", async () => {
|
|
19
|
-
render(<DefinitionEditor onChange={() => undefined} />);
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
await screen.findByText("Definition style guide"),
|
|
23
|
-
).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should be possible to change the definition", async () => {
|
|
27
|
-
const onChangeMock = jest.fn();
|
|
28
|
-
|
|
29
|
-
render(<DefinitionEditor onChange={onChangeMock} />);
|
|
30
|
-
|
|
31
|
-
const input = screen.getByRole("textbox", {
|
|
32
|
-
name: "Word to be defined:",
|
|
33
|
-
});
|
|
34
|
-
userEvent.type(input, "a");
|
|
35
|
-
|
|
36
|
-
expect(onChangeMock).toBeCalledWith(
|
|
37
|
-
expect.objectContaining({togglePrompt: "a"}),
|
|
38
|
-
undefined,
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import {Dependencies} from "@khanacademy/perseus";
|
|
2
|
-
import {render, screen} from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
import "@testing-library/jest-dom";
|
|
7
|
-
|
|
8
|
-
import {testDependencies} from "../../../../../testing/test-dependencies";
|
|
9
|
-
import DropdownEditor from "../dropdown-editor";
|
|
10
|
-
|
|
11
|
-
describe("dropdown-editor", () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.spyOn(Dependencies, "getDependencies").mockReturnValue(
|
|
14
|
-
testDependencies,
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should be possible to modify placeholder text", async () => {
|
|
19
|
-
const onChangeMock = jest.fn();
|
|
20
|
-
|
|
21
|
-
render(<DropdownEditor onChange={onChangeMock} />);
|
|
22
|
-
|
|
23
|
-
const input = screen.getByPlaceholderText("Placeholder value");
|
|
24
|
-
userEvent.type(input, "a");
|
|
25
|
-
|
|
26
|
-
expect(onChangeMock).toBeCalledWith({placeholder: "a"});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("should be possible to delete choice", async () => {
|
|
30
|
-
const onChangeMock = jest.fn();
|
|
31
|
-
|
|
32
|
-
render(<DropdownEditor onChange={onChangeMock} />);
|
|
33
|
-
|
|
34
|
-
userEvent.click(screen.getByRole("link", {name: "Delete choice"}));
|
|
35
|
-
|
|
36
|
-
expect(onChangeMock).toBeCalledWith({choices: []});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("should be possible to add choice", async () => {
|
|
40
|
-
const onChangeMock = jest.fn();
|
|
41
|
-
|
|
42
|
-
render(<DropdownEditor onChange={onChangeMock} />);
|
|
43
|
-
|
|
44
|
-
userEvent.click(screen.getByRole("link", {name: "Add a choice"}));
|
|
45
|
-
|
|
46
|
-
expect(onChangeMock).toBeCalledWith(
|
|
47
|
-
{
|
|
48
|
-
choices: [
|
|
49
|
-
{content: "", correct: false},
|
|
50
|
-
{content: "", correct: false},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
// there's some anonymous function that's also passed
|
|
54
|
-
expect.anything(),
|
|
55
|
-
);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import {Dependencies} from "@khanacademy/perseus";
|
|
2
|
-
import {render, screen} from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import * as React from "react";
|
|
5
|
-
|
|
6
|
-
import "@testing-library/jest-dom";
|
|
7
|
-
|
|
8
|
-
import {testDependencies} from "../../../../../testing/test-dependencies";
|
|
9
|
-
import ExplanationEditor from "../explanation-editor";
|
|
10
|
-
|
|
11
|
-
describe("explanation-editor", () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.spyOn(Dependencies, "getDependencies").mockReturnValue(
|
|
14
|
-
testDependencies,
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("should render", async () => {
|
|
19
|
-
render(<ExplanationEditor onChange={() => undefined} />);
|
|
20
|
-
|
|
21
|
-
expect(
|
|
22
|
-
await screen.findByText("Prompt to show explanation:"),
|
|
23
|
-
).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("should be possible to change prompt to show explanation", async () => {
|
|
27
|
-
const onChangeMock = jest.fn();
|
|
28
|
-
|
|
29
|
-
render(<ExplanationEditor onChange={onChangeMock} />);
|
|
30
|
-
|
|
31
|
-
const input = screen.getByRole("textbox", {
|
|
32
|
-
name: "Prompt to show explanation:",
|
|
33
|
-
});
|
|
34
|
-
userEvent.type(input, "a");
|
|
35
|
-
|
|
36
|
-
expect(onChangeMock).toBeCalledWith(
|
|
37
|
-
// The dropdown initalizes with "Explain"
|
|
38
|
-
expect.objectContaining({showPrompt: "Explaina"}),
|
|
39
|
-
undefined,
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("should be possible to change prompt to hide explanation", async () => {
|
|
44
|
-
const onChangeMock = jest.fn();
|
|
45
|
-
|
|
46
|
-
render(<ExplanationEditor onChange={onChangeMock} />);
|
|
47
|
-
|
|
48
|
-
const input = screen.getByRole("textbox", {
|
|
49
|
-
name: "Prompt to hide explanation:",
|
|
50
|
-
});
|
|
51
|
-
userEvent.type(input, "a");
|
|
52
|
-
|
|
53
|
-
expect(onChangeMock).toBeCalledWith(
|
|
54
|
-
// The dropdown initalizes with "Hide explain"
|
|
55
|
-
expect.objectContaining({hidePrompt: "Hide explanationa"}),
|
|
56
|
-
undefined,
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
});
|