add additional testing for #832, fixes function declaration

This commit is contained in:
Josh de Leeuw 2020-12-26 17:24:33 -05:00
parent f6ac098b4c
commit 76c5d02597
2 changed files with 40 additions and 0 deletions

View File

@ -1127,6 +1127,12 @@ jsPsych.plugins = (function() {
pretty_name: 'Post trial gap',
default: null,
description: 'Length of gap between the end of this trial and the start of the next trial'
},
css_classes: {
type: module.parameterType.STRING,
pretty_name: 'Custom CSS classes',
default: null,
description: 'A list of CSS classes to add to the jsPsych display element for the duration of this trial'
}
}

View File

@ -35,4 +35,38 @@ describe('The css_classes parameter for trials', function(){
expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false);
})
test('Class inherits in nested timelines', function(){
var tm = {
timeline: [{
type: 'html-keyboard-response',
stimulus: '<p>foo</p>',
}],
css_classes: ['foo']
}
jsPsych.init({timeline:[tm]});
expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true);
utils.pressKey(32);
expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false);
})
test('Parameter works when defined as a function', function(){
var trial = {
type: 'html-keyboard-response',
stimulus: '<p>foo</p>',
css_classes: function(){
return ['foo']
}
}
jsPsych.init({timeline:[trial]});
expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(true);
utils.pressKey(32);
expect(jsPsych.getDisplayElement().classList.contains('foo')).toBe(false);
})
})