mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 16:48:12 +00:00
testing data module
This commit is contained in:
parent
db8730d4b3
commit
d583752919
@ -22,12 +22,32 @@ describe('DataCollection', function(){
|
||||
});
|
||||
test('#select', function(){
|
||||
expect(JSON.stringify(jsPsych.data.getData().select('rt').values)).toBe(JSON.stringify([100,200,300,400,500]));
|
||||
})
|
||||
|
||||
// addToAll
|
||||
// addToLast
|
||||
// readOnly
|
||||
// push
|
||||
// count
|
||||
// values
|
||||
});
|
||||
test('#addToAll', function(){
|
||||
expect(jsPsych.data.getData().readOnly().addToAll({added: 5}).select('added').count()).toBe(5);
|
||||
});
|
||||
test('#addToLast', function(){
|
||||
jsPsych.data.getData().addToLast({lastonly: true});
|
||||
expect(jsPsych.data.getData().values()[4].lastonly).toBe(true);
|
||||
});
|
||||
test('#readOnly', function(){
|
||||
var d = jsPsych.data.getData().readOnly().values();
|
||||
d[0].rt = 0;
|
||||
expect(jsPsych.data.getData().values()[0].rt).toBe(100);
|
||||
});
|
||||
test('not #readOnly', function(){
|
||||
var d = jsPsych.data.getData().values();
|
||||
d[0].rt = 0;
|
||||
expect(jsPsych.data.getData().values()[0].rt).toBe(0);
|
||||
});
|
||||
test('#count', function(){
|
||||
expect(jsPsych.data.getData().count()).toBe(5);
|
||||
});
|
||||
test('#push', function(){
|
||||
jsPsych.data.getData().push({rt: 600, filter: true});
|
||||
expect(jsPsych.data.getData().count()).toBe(6);
|
||||
});
|
||||
test('#values', function(){
|
||||
expect(JSON.stringify(jsPsych.data.getData().values())).toBe(JSON.stringify(data));
|
||||
});
|
||||
});
|
||||
|
@ -26,4 +26,7 @@ describe('DataCollection', function(){
|
||||
test('#subset', function(){
|
||||
expect(jsPsych.data.getData().select('rt').subset(function(x){ return x > 300; }).count()).toBe(2);
|
||||
});
|
||||
test('#frequencies', function(){
|
||||
expect(jsPsych.data.getData().select('filter').frequencies()).toEqual({true:2, false: 3})
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user