mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
add test for jsPsych.endExperiment()
This commit is contained in:
parent
c112f930c1
commit
0b1b5c3cf9
49
tests/jsPsych/endexperiment.test.js
Normal file
49
tests/jsPsych/endexperiment.test.js
Normal file
@ -0,0 +1,49 @@
|
||||
const utils = require('../testing-utils.js');
|
||||
|
||||
beforeEach(function(){
|
||||
require('../../jspsych.js');
|
||||
require('../../plugins/jspsych-html-keyboard-response');
|
||||
});
|
||||
|
||||
test('works on basic timeline', function(){
|
||||
var timeline = [
|
||||
{
|
||||
type: 'html-keyboard-response',
|
||||
stimulus: 'trial 1',
|
||||
on_finish: function(){
|
||||
jsPsych.endExperiment('the end');
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'html-keyboard-response',
|
||||
stimulus: 'trial 2'
|
||||
}
|
||||
]
|
||||
|
||||
jsPsych.init({timeline});
|
||||
|
||||
expect(jsPsych.getDisplayElement().innerHTML).toMatch('trial 1');
|
||||
|
||||
utils.pressKey(32);
|
||||
|
||||
expect(jsPsych.getDisplayElement().innerHTML).toMatch('the end');
|
||||
});
|
||||
|
||||
test('works with looping timeline (#541)', function(){
|
||||
var timeline = [
|
||||
{
|
||||
timeline: [{type: 'html-keyboard-response', stimulus: 'trial 1'}],
|
||||
loop_function: function(){
|
||||
jsPsych.endExperiment('the end')
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
jsPsych.init({timeline});
|
||||
|
||||
expect(jsPsych.getDisplayElement().innerHTML).toMatch('trial 1');
|
||||
|
||||
utils.pressKey(32);
|
||||
|
||||
expect(jsPsych.getDisplayElement().innerHTML).toMatch('the end');
|
||||
});
|
Loading…
Reference in New Issue
Block a user