Merge pull request #1126 from becky-gilbert/data-first-last-tests

New tests for data collection .first and .last
This commit is contained in:
Josh de Leeuw 2020-10-20 15:43:52 -04:00 committed by GitHub
commit 559dac613e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,10 +67,32 @@ describe('DataCollection', function(){
test('#first', function(){
expect(jsPsych.data.get().first(3).count()).toBe(3);
expect(jsPsych.data.get().first(2).values()[1].rt).toBe(200);
expect(jsPsych.data.get().first().count()).toBe(1);
expect(() => {
jsPsych.data.get().first(-1)
}).toThrow();
expect(() => {
jsPsych.data.get().first(0)
}).toThrow();
expect(jsPsych.data.get().filter({foo: "bar"}).first(1).count()).toBe(0);
var n = jsPsych.data.get().count();
var too_many = n+1;
expect(jsPsych.data.get().first(too_many).count()).toBe(n);
});
test('#last', function(){
expect(jsPsych.data.get().last(2).count(2)).toBe(2);
expect(jsPsych.data.get().last(2).values()[0].rt).toBe(400);
expect(jsPsych.data.get().last().count()).toBe(1);
expect(() => {
jsPsych.data.get().last(-1)
}).toThrow();
expect(() => {
jsPsych.data.get().last(0)
}).toThrow();
expect(jsPsych.data.get().filter({foo: "bar"}).last(1).count()).toBe(0);
var n = jsPsych.data.get().count();
var too_many = n+1;
expect(jsPsych.data.get().last(too_many).count()).toBe(n);
});
test('#join', function(){
var dc1 = jsPsych.data.get().filter({filter: true});