Skip to content

Commit

Permalink
adds a test for #990
Browse files Browse the repository at this point in the history
  • Loading branch information
jodeleeuw committed Oct 22, 2020
1 parent 56a74ac commit b8ad672
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/jsPsych/default-parameters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,32 @@ describe('nested defaults', function(){
expect(display.querySelector('input').placeholder).toBe("")
expect(display.querySelector('input').size).toBe(40)
});

test('safe against extending the array.prototype (issue #989)', function(){
Array.prototype.qq = jest.fn();
const spy = jest.spyOn(console, 'error').mockImplementation();

var t = {
type: 'survey-text',
questions: [
{
prompt: 'Question 1.'
},
{
prompt: 'Question 2.'
}
]
}

jsPsych.init({timeline: [t]})

var display = jsPsych.getDisplayElement();

expect(display.querySelector('input').placeholder).toBe("")
expect(display.querySelector('input').size).toBe(40)

expect(spy).not.toHaveBeenCalled();

spy.mockRestore();
});
})

0 comments on commit b8ad672

Please sign in to comment.