sync with jspsych master
This commit is contained in:
Becky Gilbert 2020-10-20 12:25:33 -07:00
commit d2a039f04b
5 changed files with 2035 additions and 2217 deletions

4186
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
},
"homepage": "https://github.com/jspsych/jsPsych#readme",
"devDependencies": {
"jest": "^24.8"
"jest": "^26.6"
},
"jest": {
"resetModules": true,

View File

@ -217,7 +217,7 @@ jsPsych.plugins["image-button-response"] = (function() {
end_trial();
}, trial.trial_duration);
} 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.");
}
};

View File

@ -175,7 +175,7 @@ jsPsych.plugins["image-keyboard-response"] = (function() {
end_trial();
}, trial.trial_duration);
} 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.");
}
};

View File

@ -347,3 +347,63 @@ describe('endCurrentTimeline', function(){
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);
});
});