Skip to content

Commit

Permalink
Fix renderer-related tests (except renderer_api tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremywiebe committed Mar 24, 2023
1 parent 5202dd6 commit 2e9838c
Show file tree
Hide file tree
Showing 8 changed files with 664 additions and 464 deletions.
35 changes: 25 additions & 10 deletions packages/perseus/src/__testdata__/renderer_testdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type {
DropdownWidget,
ImageWidget,
InputNumberWidget,
NumericInputWidget,
PerseusRenderer,
} from "../perseus-types.js";

Expand Down Expand Up @@ -48,21 +48,36 @@ export const imageWidget: ImageWidget = {
version: {major: 0, minor: 0},
};

export const inputNumberWidget: InputNumberWidget = {
export const numericInputWidget: NumericInputWidget = {
version: {
major: 0,
minor: 0,
},
type: "input-number",
type: "numeric-input",
graded: true,
alignment: "default",
options: {
maxError: 0.1,
inexact: false,
value: 0.3333333333333333,
simplify: "optional",
answerType: "rational",
answers: [
{
message: "That's correct!",
value: 0.3333333333333333,
status: "correct",
answerForms: ["integer", "proper", "improper", "mixed"],
strict: true,
maxError: 0.1,
simplify: "optional",
},
],
answerForms: [
{name: "integer", simplify: "required"},
{name: "proper", simplify: "required"},
{name: "improper", simplify: "required"},
{name: "mixed", simplify: "required"},
],
size: "normal",
coefficient: false,
static: false,
labelText: "Enter the decimal value of 1/3",
},
};

Expand All @@ -75,15 +90,15 @@ export const question1: PerseusRenderer = {

export const question2: PerseusRenderer = {
content:
"Denis baked a peach pie and cut it into $3$ equal-sized pieces. Denis's dad eats $1$ section of the pie. \n\n**What fraction of the pie did Denis's dad eat?** \n![](https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png) \n[[\u2603 input-number 1]] \n\n\n\n",
"Denis baked a peach pie and cut it into $3$ equal-sized pieces. Denis's dad eats $1$ section of the pie. \n\n**What fraction of the pie did Denis's dad eat?** \n![](https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png) \n[[\u2603 numeric-input 1]] \n\n\n\n",
images: {
"https://ka-perseus-graphie.s3.amazonaws.com/74a2b7583a2c26ebfb3ad714e29867541253fc97.png":
{
width: 200,
height: 200,
},
},
widgets: {"input-number 1": inputNumberWidget},
widgets: {"numeric-input 1": numericInputWidget},
};

// Note that if this item is used, you _must_ first register the MockWidget
Expand Down
255 changes: 142 additions & 113 deletions packages/perseus/src/__tests__/__snapshots__/item-renderer_test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,149 +43,178 @@ exports[`item renderer should snapshot: initial render 1`] = `
<div
class="perseus-widget-container widget-nohighlight widget-inline-block"
>
<span>
<div>
<input
autocapitalize="off"
autocomplete="off"
autocorrect="off"
class="input_1t4b01j-o_O-LabelMedium_1rew30o-o_O-default_1r2dwp3-o_O-default_1gznapd-o_O-leftAlign_7jg4r4"
id="input-with-examples-aW5wdXQtbnVtYmVyIDE"
type="text"
value=""
/>
</div>
<div
style="position: relative; height: 0px; display: none;"
>
<div>
<span>
<div>
<input
aria-label="Your answer:"
autocapitalize="off"
autocomplete="off"
autocorrect="off"
class="input_1t4b01j-o_O-LabelMedium_1rew30o-o_O-default_1r2dwp3-o_O-input_19vw1dn"
id="input-with-examples-aW5wdXQtbnVtYmVyIDE"
type="text"
value=""
/>
</div>
<div
class="tooltipContainer"
style="position: absolute; left: 0px;"
style="position: relative; height: 0px; display: none;"
>
<div
style="display: block; position: relative; visibility: visible; left: 0px; top: -1px; width: 12px; height: 11px; margin-top: -1px; margin-bottom: -2px; z-index: 10;"
class="tooltipContainer"
style="position: absolute; left: 0px;"
>
<div
style="display: block; height: 0px; width: 0px; position: absolute; left: 0px; top: -1px; border-right: 12px solid transparent; border-bottom: 12px solid #ccc;"
/>
<div
style="display: block; height: 0px; width: 0px; position: absolute; left: 1px; top: 1px; border-right: 10px solid transparent; border-bottom: 10px solid white;"
/>
</div>
<div
class="perseus-formats-tooltip preview-measure"
style="position: relative; top: 0px; left: 0px; border: 1px solid #ccc; box-shadow: 0 1px 3px #ccc; z-index: 9;"
>
style="display: block; position: relative; visibility: visible; left: 0px; top: -1px; width: 12px; height: 11px; margin-top: -1px; margin-bottom: -2px; z-index: 10;"
>
<div
style="display: block; height: 0px; width: 0px; position: absolute; left: 0px; top: -1px; border-right: 12px solid transparent; border-bottom: 12px solid #ccc;"
/>
<div
style="display: block; height: 0px; width: 0px; position: absolute; left: 1px; top: 1px; border-right: 10px solid transparent; border-bottom: 10px solid white;"
/>
</div>
<div
id="input-with-examples-aW5wdXQtbnVtYmVyIDE"
class="perseus-formats-tooltip preview-measure"
style="position: relative; top: 0px; left: 0px; border: 1px solid #ccc; box-shadow: 0 1px 3px #ccc; z-index: 9;"
>
<span
class="mock-KatexProvider"
<div
id="input-with-examples-aW5wdXQtbnVtYmVyIDE"
>
<div
class="perseus-renderer perseus-renderer-responsive"
<span
class="mock-KatexProvider"
>
<div
class="paragraph"
data-perseus-paragraph-index="0"
class="perseus-renderer perseus-renderer-responsive"
>
<ul>
<li>
<strong>
Your answer should be
</strong>
</li>
<li>
an integer, like
<span
style="white-space: nowrap;"
>
<span />
<div
class="paragraph"
data-perseus-paragraph-index="0"
>
<ul>
<li>
<strong>
Your answer should be
</strong>
</li>
<li>
an integer, like
<span
style="white-space: nowrap;"
>
<span />
<span
class="mock-TeX"
>
6
</span>
<span />
</span>
</li>
<li>
a
<em>
simplified proper
</em>
fraction, like
<span
style="white-space: nowrap;"
>
<span />
<span
class="mock-TeX"
>
3/5
</span>
<span />
</span>
</li>
<li>
a
<em>
simplified improper
</em>
fraction, like
<span
class="mock-TeX"
style="white-space: nowrap;"
>
6
<span />
<span
class="mock-TeX"
>
7/4
</span>
<span />
</span>
<span />
</span>
</li>
<li>
an
<em>
exact
</em>
decimal, like
<span
style="white-space: nowrap;"
>
<span />
</li>
<li>
a mixed number, like
<span
class="mock-TeX"
style="white-space: nowrap;"
>
0.75
<span />
<span
class="mock-TeX"
>
1\\ 3/4
</span>
<span />
</span>
<span />
</span>
</li>
<li>
a
<em>
simplified proper
</em>
fraction, like
<span
style="white-space: nowrap;"
>
<span />
</li>
<li>
an
<em>
exact
</em>
decimal, like
<span
class="mock-TeX"
style="white-space: nowrap;"
>
3/5
<span />
<span
class="mock-TeX"
>
0.75
</span>
<span />
</span>
<span />
</span>
</li>
<li>
a
<em>
simplified improper
</em>
fraction, like
<span
style="white-space: nowrap;"
>
<span />
</li>
<li>
a multiple of pi, like
<span
class="mock-TeX"
style="white-space: nowrap;"
>
7/4
<span />
<span
class="mock-TeX"
>
12\\ \\text{pi}
</span>
<span />
</span>
<span />
</span>
</li>
<li>
a mixed number, like
<span
style="white-space: nowrap;"
>
<span />
or
<span
class="mock-TeX"
style="white-space: nowrap;"
>
1\\ 3/4
<span />
<span
class="mock-TeX"
>
2/3\\ \\text{pi}
</span>
<span />
</span>
<span />
</span>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</span>
</span>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 2e9838c

Please sign in to comment.