-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
//import { JsPsych } from "../../src/JsPsych"; | ||
import { TestExtension } from "../extensions/TestExtension"; | ||
import TestPlugin from "../TestPlugin"; | ||
|
||
const jsPsychApaCitation = | ||
"de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351"; | ||
"de Leeuw, J. R., Gilbert, R. A., & Luchterhandt, B. (2023). jsPsych: Enabling an Open-Source Collaborative Ecosystem of Behavioral Experiments. Journal of Open Source Software, 8(85), 5351. https://doi.org/10.21105/joss.05351 "; | ||
const jsPsychBibtexCitation = | ||
'@misc{LeeuwjsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, doi = {10.5281/zenodo.7702307}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, } @article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '; | ||
'@article{Leeuw2023jsPsych, author = {de Leeuw, Joshua R. and Gilbert, Rebecca A. and Luchterhandt, Bj{\\" o}rn}, journal = {Journal of Open Source Software}, doi = {10.21105/joss.05351}, issn = {2475-9066}, number = {85}, year = {2023}, month = {may 11}, pages = {5351}, publisher = {Open Journals}, title = {jsPsych: Enabling an {Open}-{Source} {Collaborative} {Ecosystem} of {Behavioral} {Experiments}}, url = {https://joss.theoj.org/papers/10.21105/joss.05351}, volume = {8}, } '; | ||
const testPluginApaCitation = "Test plugin APA citation"; | ||
const testPluginBibtexCitation = "Test plugin BibTeX citation"; | ||
const testExtensionApaCitation = "Test extension APA citation"; | ||
|
@@ -37,7 +36,10 @@ try { | |
}); | ||
|
||
describe("citing not using an array", () => { | ||
test("citing nothing", () => { | ||
test("citing without input", () => { | ||
expect(jspsych.getCitations()).toBe(jsPsychApaCitation); | ||
Check failure on line 40 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing not using an array › citing without input
Check failure on line 40 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing not using an array › citing without input
Check failure on line 40 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing not using an array › citing without input
|
||
}); | ||
test("citing null", () => { | ||
expect(() => jspsych.getCitations(null)).toThrow("Expected array of plugins/extensions"); | ||
}); | ||
test("citing without input and with invalid format", () => { | ||
|
@@ -49,20 +51,18 @@ try { | |
|
||
describe("citing using an array in different formats", () => { | ||
test("citing empty array with APA format", () => { | ||
jspsych.getCitations([], "apa"); | ||
expect(consoleWarnSpy.mock.calls[0][0]).toBe("No plugins/extensions provided"); | ||
expect(jspsych.getCitations([], "apa")).toBe(jsPsychApaCitation); | ||
Check failure on line 54 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing using an array in different formats › citing empty array with APA format
Check failure on line 54 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing empty array with APA format
Check failure on line 54 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing empty array with APA format
|
||
}); | ||
test("citing empty array with BibTeX format", () => { | ||
jspsych.getCitations([], "bibtex"); | ||
expect(consoleWarnSpy.mock.calls[0][0]).toBe("No plugins/extensions provided"); | ||
expect(jspsych.getCitations([], "bibtex")).toBe(jsPsychBibtexCitation); | ||
Check failure on line 57 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing using an array in different formats › citing empty array with BibTeX format
Check failure on line 57 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing empty array with BibTeX format
Check failure on line 57 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing empty array with BibTeX format
|
||
}); | ||
test("citing empty array without format", () => { | ||
jspsych.getCitations([]); | ||
expect(consoleWarnSpy.mock.calls[0][0]).toBe("No plugins/extensions provided"); | ||
expect(jspsych.getCitations([])).toBe(jsPsychApaCitation); | ||
Check failure on line 60 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing using an array in different formats › citing empty array without format
Check failure on line 60 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing empty array without format
Check failure on line 60 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing empty array without format
|
||
}); | ||
test("citing one plugin with valid format in all caps", () => { | ||
jspsych.getCitations([TestPlugin], "APA"); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginApaCitation); | ||
expect(jspsych.getCitations([TestPlugin], "APA")).toBe( | ||
Check failure on line 63 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing using an array in different formats › citing one plugin with valid format in all caps
Check failure on line 63 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing one plugin with valid format in all caps
Check failure on line 63 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing using an array in different formats › citing one plugin with valid format in all caps
|
||
jsPsychApaCitation + "\n" + testPluginApaCitation | ||
); | ||
}); | ||
test("citing with unsupported format", () => { | ||
expect(() => jspsych.getCitations([TestPlugin], "DummyTex")).toThrow( | ||
|
@@ -73,24 +73,24 @@ try { | |
|
||
describe("citing mix of valid plugins/extensions", () => { | ||
test("citing a plugin", () => { | ||
jspsych.getCitations([TestPlugin]); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginApaCitation); | ||
expect(jspsych.getCitations([TestPlugin])).toBe( | ||
Check failure on line 76 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing mix of valid plugins/extensions › citing a plugin
Check failure on line 76 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing a plugin
Check failure on line 76 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing a plugin
|
||
jsPsychApaCitation + "\n" + testPluginApaCitation | ||
); | ||
}); | ||
test("citing a plugin in BibTeX", () => { | ||
jspsych.getCitations([TestPlugin], "bibtex"); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginBibtexCitation); | ||
expect(jspsych.getCitations([TestPlugin], "bibtex")).toBe( | ||
Check failure on line 81 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing mix of valid plugins/extensions › citing a plugin in BibTeX
Check failure on line 81 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing a plugin in BibTeX
Check failure on line 81 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing a plugin in BibTeX
|
||
jsPsychBibtexCitation + "\n" + testPluginBibtexCitation | ||
); | ||
}); | ||
test("citing multiple plugins", () => { | ||
jspsych.getCitations([TestPlugin, TestPlugin]); | ||
expect(consoleLogSpy.mock.calls).toHaveLength(2); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginApaCitation); | ||
expect(consoleLogSpy.mock.calls[1][0]).toBe(testPluginApaCitation); | ||
expect(jspsych.getCitations([TestPlugin, TestPlugin])).toBe( | ||
Check failure on line 86 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing mix of valid plugins/extensions › citing multiple plugins
Check failure on line 86 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing multiple plugins
Check failure on line 86 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing multiple plugins
|
||
jsPsychApaCitation + "\n" + testPluginApaCitation | ||
); | ||
}); | ||
test("citing mix of plugins and extensions", () => { | ||
jspsych.getCitations([TestPlugin, TestExtension]); | ||
expect(consoleLogSpy.mock.calls).toHaveLength(2); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginApaCitation); | ||
expect(consoleLogSpy.mock.calls[1][0]).toBe(testExtensionApaCitation); | ||
expect(jspsych.getCitations([TestPlugin, TestExtension])).toBe( | ||
Check failure on line 91 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 18citing mix of valid plugins/extensions › citing mix of plugins and extensions
Check failure on line 91 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing mix of plugins and extensions
Check failure on line 91 in packages/jspsych/tests/citations/citations.test.ts GitHub Actions / Build, lint, and test on Node.js 20citing mix of valid plugins/extensions › citing mix of plugins and extensions
|
||
jsPsychApaCitation + "\n" + testPluginApaCitation + "\n" + testExtensionApaCitation | ||
); | ||
}); | ||
}); | ||
} catch (e) { | ||
|