import { startTimeline } from "@jspsych/test-utils";
import freeSort from ".";
jest.useFakeTimers();
describe("free-sort plugin", () => {
test("should display stimuli", async () => {
const { getHTML } = await startTimeline([
{
type: freeSort,
stimuli: [
"img/happy_face_1.jpg",
"img/happy_face_2.jpg",
"img/happy_face_3.jpg",
"img/happy_face_4.jpg",
],
},
]);
for (let i = 1; i < 5; i++) {
expect(getHTML()).toContain(
`src="img/happy_face_${i}.jpg" data-src="img/happy_face_${i}.jpg"`
);
}
});
test("should be able to adjust the height and width of free-sort area", async () => {
const { getHTML } = await startTimeline([
{
type: freeSort,
stimuli: [
"img/happy_face_1.jpg",
"img/happy_face_2.jpg",
"img/happy_face_3.jpg",
"img/happy_face_4.jpg",
],
sort_area_height: 500,
sort_area_width: 700,
},
]);
expect(getHTML()).toContain(
'class="jspsych-free-sort-arena" style="position: relative; width:700px; height:500px;'
);
});
test("should be able to adjust the height and width of stimuli", async () => {
const { getHTML } = await startTimeline([
{
type: freeSort,
stimuli: [
"img/happy_face_1.jpg",
"img/happy_face_2.jpg",
"img/happy_face_3.jpg",
"img/happy_face_4.jpg",
],
stim_height: 200,
stim_width: 200,
},
]);
expect(getHTML()).toMatch(/ {
const { getHTML } = await startTimeline([
{
type: freeSort,
stimuli: [
"img/happy_face_1.jpg",
"img/happy_face_2.jpg",
"img/happy_face_3.jpg",
"img/happy_face_4.jpg",
],
prompt: "
This is a prompt
", }, ]); expect(getHTML()).toContain("This is a prompt
"); }); test('should display prompt at bottom if prompt_location is "below"', async () => { const { getHTML } = await startTimeline([ { type: freeSort, stimuli: [ "img/happy_face_1.jpg", "img/happy_face_2.jpg", "img/happy_face_3.jpg", "img/happy_face_4.jpg", ], prompt: "This is a prompt
", prompt_location: "below", }, ]); expect(getHTML()).toMatch(/This is a prompt<\/p>.+