Skip to content

Commit

Permalink
Migrate additional doenetml worker tests to vitest (#245)
Browse files Browse the repository at this point in the history
Converts another group of cypress tests that don't need to test the DOM to vitest.

A few small bug fixes identified in the conversion are included.
  • Loading branch information
dqnykamp authored Oct 22, 2024
1 parent 578e6f1 commit bd5617a
Show file tree
Hide file tree
Showing 59 changed files with 49,681 additions and 103,880 deletions.
2 changes: 1 addition & 1 deletion packages/doenetml-worker/src/components/Answer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ export default class Answer extends InlineComponent {
) {
warnings.push({
message:
"An award for this answer is based on the answer's own submitted response, which will lead to unexpected behavior.",
"An award for this answer is based on the answer tag's own submitted response, which will lead to unexpected behavior.",
level: 1,
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/doenetml-worker/src/components/AsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export default class AsList extends InlineComponent {
inlineChildren: {
dependencyType: "child",
childGroups: ["inline"],
variableNames: ["text"],
variableNames: ["text", "hidden"],
variablesOptional: true,
},
}),
definition: function ({ dependencyValues }) {
let textpieces =
dependencyValues.inlineChildren.map(textFromComponent);

let text = textpieces.join(", ");
let text = textpieces.filter((x) => x).join(", ");

return { setValue: { text } };
},
Expand Down
4 changes: 2 additions & 2 deletions packages/doenetml-worker/src/components/Curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -4149,7 +4149,7 @@ function getNearestPointFunctionCurve({ dependencyValues, numerics }) {
return result;
}

// if we don't have finite values for both componentts
// if we don't have finite values for both components
// there's nothing more we can do
if (!(Number.isFinite(x1) && Number.isFinite(x2))) {
return {};
Expand Down Expand Up @@ -4183,7 +4183,7 @@ function getNearestPointFunctionCurve({ dependencyValues, numerics }) {
if (parMin !== -Infinity) {
minT = parMin;
}
if (parMax !== -Infinity) {
if (parMax !== Infinity) {
maxT = parMax;
}

Expand Down
21 changes: 21 additions & 0 deletions packages/doenetml-worker/src/components/Lists.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BlockComponent from "./abstract/BlockComponent";
import BaseComponent from "./abstract/BaseComponent";
import { textFromChildren } from "../utils/text";

export class Ol extends BlockComponent {
constructor(args) {
Expand Down Expand Up @@ -172,6 +173,26 @@ export class Li extends BaseComponent {
definition: () => ({ setValue: { item: true } }),
};

stateVariableDefinitions.text = {
public: true,
shadowingInstructions: {
createComponentOfType: "text",
},
returnDependencies: () => ({
children: {
dependencyType: "child",
childGroups: ["anything"],
variableNames: ["text", "hidden"],
variablesOptional: true,
},
}),
definition: function ({ dependencyValues }) {
let text = textFromChildren(dependencyValues.children);

return { setValue: { text } };
},
};

return stateVariableDefinitions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class SelectRandomNumbers extends SampleRandomNumbers {
let attributes = super.createAttributesObject();

delete attributes.numSamples;
delete attributes.variantDeterminesSeed;

attributes.assignNamesSkip = {
createPrimitiveOfType: "number",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1462,7 +1462,7 @@ describe("Answer tag tests", async () => {
expect(errorWarnings.warnings.length).eq(1);

expect(errorWarnings.warnings[0].message).contain(
"An award for this answer is based on the answer's own submitted response",
"An award for this answer is based on the answer tag's own submitted response",
);
expect(errorWarnings.warnings[0].level).eq(1);
expect(errorWarnings.warnings[0].doenetMLrange.lineBegin).eq(2);
Expand Down
Loading

0 comments on commit bd5617a

Please sign in to comment.