mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-11 16:18:11 +00:00
add additional testing for #832, fixes function declaration
This commit is contained in:
parent
f6ac098b4c
commit
76c5d02597
@ -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'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user