mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
Merge branch 'master' of https://github.com/jspsych/jsPsych
sync with jspsych master
This commit is contained in:
commit
d2a039f04b
4158
package-lock.json
generated
4158
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,7 +20,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/jspsych/jsPsych#readme",
|
"homepage": "https://github.com/jspsych/jsPsych#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"jest": "^24.8"
|
"jest": "^26.6"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"resetModules": true,
|
"resetModules": true,
|
||||||
|
@ -217,7 +217,7 @@ jsPsych.plugins["image-button-response"] = (function() {
|
|||||||
end_trial();
|
end_trial();
|
||||||
}, trial.trial_duration);
|
}, trial.trial_duration);
|
||||||
} else if (trial.response_ends_trial === false) {
|
} else if (trial.response_ends_trial === false) {
|
||||||
console.warn("The experiment may be stuck in a loop. Try setting a trial duration or set response_ends_trial to true.");
|
console.warn("The experiment may be deadlocked. Try setting a trial duration or set response_ends_trial to true.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ jsPsych.plugins["image-keyboard-response"] = (function() {
|
|||||||
end_trial();
|
end_trial();
|
||||||
}, trial.trial_duration);
|
}, trial.trial_duration);
|
||||||
} else if (trial.response_ends_trial === false) {
|
} else if (trial.response_ends_trial === false) {
|
||||||
console.warn("The experiment may be stuck in a loop. Try setting a trial duration or set response_ends_trial to true.");
|
console.warn("The experiment may be deadlocked. Try setting a trial duration or set response_ends_trial to true.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -347,3 +347,63 @@ describe('endCurrentTimeline', function(){
|
|||||||
utils.pressKey(32);
|
utils.pressKey(32);
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('add node to end of timeline', function(){
|
||||||
|
|
||||||
|
test('adds node to end of timeline, without callback', function() {
|
||||||
|
var new_trial = {
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'bar'
|
||||||
|
};
|
||||||
|
|
||||||
|
var new_timeline = {
|
||||||
|
timeline: [new_trial]
|
||||||
|
};
|
||||||
|
|
||||||
|
var timeline = [
|
||||||
|
{
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'foo',
|
||||||
|
on_start: function() {
|
||||||
|
jsPsych.addNodeToEndOfTimeline(new_timeline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: timeline
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch('foo');
|
||||||
|
utils.pressKey(32);
|
||||||
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch('bar');
|
||||||
|
utils.pressKey(32);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('adds node to end of timeline, with callback', function() {
|
||||||
|
var t = {
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'foo',
|
||||||
|
on_finish: function(){
|
||||||
|
jsPsych.pauseExperiment();
|
||||||
|
jsPsych.addNodeToEndOfTimeline({
|
||||||
|
timeline: [{
|
||||||
|
type: 'html-keyboard-response',
|
||||||
|
stimulus: 'bar'
|
||||||
|
}]
|
||||||
|
}, jsPsych.resumeExperiment)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
jsPsych.init({
|
||||||
|
timeline: [t]
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch('foo');
|
||||||
|
utils.pressKey(32);
|
||||||
|
expect(jsPsych.getDisplayElement().innerHTML).toMatch('bar');
|
||||||
|
utils.pressKey(32);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user