mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
Add test case for missing plugin type/info
This commit is contained in:
parent
d8653b0760
commit
4035041967
@ -36,6 +36,16 @@ describe("Trial", () => {
|
||||
return trial;
|
||||
};
|
||||
|
||||
it("throws an error upon construction when the `type` parameter or plugin info object is undefined", () => {
|
||||
for (const description of [{}, { type: {} }] as TrialDescription[]) {
|
||||
expect(
|
||||
() => new Trial(dependencies, description, timeline)
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
"\"Trial plugin not recognized. Please provide a valid plugin using the 'type' parameter.\""
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
describe("run()", () => {
|
||||
it("instantiates the corresponding plugin", async () => {
|
||||
const trial = createTrial({ type: TestPlugin });
|
||||
|
@ -35,12 +35,12 @@ export class Trial extends TimelineNode {
|
||||
|
||||
this.trialObject = deepCopy(description);
|
||||
this.pluginClass = this.getParameterValue("type", { evaluateFunctions: false });
|
||||
if (this.pluginClass === undefined || this.pluginClass["info"] === undefined) {
|
||||
this.pluginInfo = this.pluginClass?.["info"];
|
||||
if (!this.pluginInfo) {
|
||||
throw new Error(
|
||||
"Trial plugin not recognized. Please provide a valid plugin using the 'type' parameter."
|
||||
);
|
||||
}
|
||||
this.pluginInfo = this.pluginClass["info"];
|
||||
|
||||
if (!("version" in this.pluginInfo) && !("data" in this.pluginInfo)) {
|
||||
console.warn(
|
||||
|
Loading…
Reference in New Issue
Block a user