-
-
Notifications
You must be signed in to change notification settings - Fork 681
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d5215e
commit f0bc8ae
Showing
17 changed files
with
325 additions
and
1,005 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
cff-version: "1.2.0" | ||
authors: | ||
- family-names: Leeuw | ||
given-names: Joshua R. | ||
name-particle: de | ||
orcid: "https://orcid.org/0000-0003-4815-2364" | ||
- family-names: Gilbert | ||
given-names: Rebecca A. | ||
orcid: "https://orcid.org/0000-0003-4574-7792" | ||
- family-names: Luchterhandt | ||
given-names: Björn | ||
orcid: "https://orcid.org/0000-0002-9225-2787" | ||
contact: | ||
- family-names: Leeuw | ||
given-names: Joshua R. | ||
name-particle: de | ||
orcid: "https://orcid.org/0000-0003-4815-2364" | ||
doi: 10.5281/zenodo.7702307 | ||
message: If you use this software, please cite our article in the | ||
Journal of Open Source Software. | ||
preferred-citation: | ||
authors: | ||
- family-names: Leeuw | ||
given-names: Joshua R. | ||
name-particle: de | ||
orcid: "https://orcid.org/0000-0003-4815-2364" | ||
- family-names: Gilbert | ||
given-names: Rebecca A. | ||
orcid: "https://orcid.org/0000-0003-4574-7792" | ||
- family-names: Luchterhandt | ||
given-names: Björn | ||
orcid: "https://orcid.org/0000-0002-9225-2787" | ||
date-published: 2023-05-11 | ||
doi: 10.21105/joss.05351 | ||
issn: 2475-9066 | ||
issue: 85 | ||
journal: Journal of Open Source Software | ||
publisher: | ||
name: Open Journals | ||
start: 5351 | ||
title: "jsPsych: Enabling an Open-Source Collaborative Ecosystem of | ||
Behavioral Experiments" | ||
type: article | ||
url: "https://joss.theoj.org/papers/10.21105/joss.05351" | ||
volume: 8 | ||
title: "jsPsych: Enabling an Open-Source Collaborative Ecosystem of | ||
Behavioral Experiments" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { JsPsych } from "../../src/JsPsych"; | ||
import { TestExtension } from "../extensions/TestExtension"; | ||
import TestPlugin from "../TestPlugin"; | ||
|
||
const testPluginApaCitation = "Test plugin APA citation"; | ||
const testPluginBibtexCitation = "Test plugin BibTeX citation"; | ||
const testExtensionApaCitation = "Test extension APA citation"; | ||
|
||
let jspsych: JsPsych; | ||
let consoleLogSpy: jest.SpyInstance; | ||
let consoleWarnSpy: jest.SpyInstance; | ||
|
||
beforeEach(() => { | ||
jspsych = new JsPsych(); | ||
consoleLogSpy = jest.spyOn(console, "log").mockImplementation(); | ||
consoleWarnSpy = jest.spyOn(console, "warn").mockImplementation(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
describe("citing not using an array", () => { | ||
test("citing nothing", () => { | ||
expect(() => jspsych.getCitations(null)).toThrow("Expected array of plugins/extensions"); | ||
}); | ||
test("citing without input and with invalid format", () => { | ||
expect(() => jspsych.getCitations(null, "apa")).toThrow("Expected array of plugins/extensions"); | ||
}); | ||
}); | ||
|
||
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"); | ||
}); | ||
test("citing empty array with BibTeX format", () => { | ||
jspsych.getCitations([], "bibtex"); | ||
expect(consoleWarnSpy.mock.calls[0][0]).toBe("No plugins/extensions provided"); | ||
}); | ||
test("citing empty array without format", () => { | ||
jspsych.getCitations([]); | ||
expect(consoleWarnSpy.mock.calls[0][0]).toBe("No plugins/extensions provided"); | ||
}); | ||
test("citing one plugin with valid format in all caps", () => { | ||
jspsych.getCitations([TestPlugin], "APA"); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginApaCitation); | ||
}); | ||
test("citing with unsupported format", () => { | ||
expect(() => jspsych.getCitations([TestPlugin], "DummyTex")).toThrow( | ||
"Unsupported citation format" | ||
); | ||
}); | ||
}); | ||
|
||
describe("citing mix of valid plugins/extensions", () => { | ||
test("citing a plugin", () => { | ||
jspsych.getCitations([TestPlugin]); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(testPluginApaCitation); | ||
}); | ||
test("citing a plugin in BibTeX", () => { | ||
jspsych.getCitations([TestPlugin], "bibtex"); | ||
expect(consoleLogSpy.mock.calls[0][0]).toBe(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); | ||
}); | ||
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); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.