Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimum_valid_rt #546

Merged
merged 4 commits into from Oct 23, 2020
Merged

minimum_valid_rt #546

merged 4 commits into from Oct 23, 2020

Conversation

andytwoods
Copy link
Contributor

As per #542, a way to have a minimum RT before button presses are acknowledged.

Below, some tests I've failed to add. I couldnt override Date.now() within getKeyboardResponse without further code changes within the embedded listener function. Something for the future :)

test('should execute a function after successful keypress and after minimum_valid_rt', function(){


    var mockedDate = new Date(2017, 11, 10, 0, 0, 0)
    global.Date = jest.fn(() => mockedDate)

    var minimum_valid_rt = 1000

    var callback = jest.fn();
    jsPsych.pluginAPI.getKeyboardResponse({callback_function: callback, minimum_valid_rt: minimum_valid_rt,
        rt_method: 'date' });
    expect(callback.mock.calls.length).toBe(0);

    document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
    expect(callback.mock.calls.length).toBe(0);

    mockedDate = new Date(2017, 11, 10, 0, 0, minimum_valid_rt)
    global.Date = jest.fn(() => mockedDate)

    document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
    expect(callback.mock.calls.length).toBe(0);

    mockedDate = new Date(2017, 11, 10, 0, 0, minimum_valid_rt+1)
    global.Date = jest.fn(() => mockedDate)

    document.querySelector('.jspsych-display-element').dispatchEvent(new KeyboardEvent('keydown', {keyCode: 32}));
    expect(callback.mock.calls.length).toBe(0);

    });

@jodeleeuw jodeleeuw self-assigned this Jul 2, 2018
@jodeleeuw jodeleeuw added this to the 6.1 milestone Jul 2, 2018
@twiecki
Copy link

twiecki commented Jul 3, 2019

Thanks!

@jodeleeuw jodeleeuw modified the milestones: 6.1, 6.2 Jul 11, 2019
@jodeleeuw jodeleeuw changed the base branch from master to min-rt October 23, 2020 14:02
@jodeleeuw jodeleeuw merged commit a7916b8 into jspsych:min-rt Oct 23, 2020
jodeleeuw added a commit that referenced this pull request Oct 23, 2020
@becky-gilbert becky-gilbert mentioned this pull request Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants