compileprofile-spacetests 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +115 -0
- package/README.md +147 -34
- package/dist/cjs/common-interfaces.d.ts +60 -0
- package/dist/cjs/common-interfaces.js +2 -0
- package/dist/cjs/emotions.d.ts +2 -7
- package/dist/cjs/emotions.js +56 -22
- package/dist/cjs/gonogo.d.ts +1 -6
- package/dist/cjs/gonogo.js +61 -14
- package/dist/cjs/index.d.ts +2 -5
- package/dist/cjs/nback.d.ts +1 -11
- package/dist/cjs/nback.js +27 -13
- package/dist/cjs/spatial-cognition.d.ts +1 -6
- package/dist/cjs/spatial-cognition.js +69 -14
- package/dist/esm/common-interfaces.d.ts +60 -0
- package/dist/esm/common-interfaces.js +1 -0
- package/dist/esm/emotions.d.ts +2 -7
- package/dist/esm/emotions.js +55 -21
- package/dist/esm/gonogo.d.ts +1 -6
- package/dist/esm/gonogo.js +61 -14
- package/dist/esm/index.d.ts +2 -5
- package/dist/esm/nback.d.ts +1 -11
- package/dist/esm/nback.js +27 -13
- package/dist/esm/spatial-cognition.d.ts +1 -6
- package/dist/esm/spatial-cognition.js +69 -14
- package/example-data/emotions.json +807 -807
- package/example-data/gonogo.json +5392 -5392
- package/example-data/nback.json +892 -892
- package/example-data/participant.json +6 -6
- package/example-data/spatial-cognition.json +462 -462
- package/jest.config.js +13 -13
- package/original/emotion-recognition.R +39 -39
- package/original/gonogo.R +32 -32
- package/package.json +40 -40
- package/src/__tests__/integration/browserInfo.test.ts +16 -16
- package/src/__tests__/integration/emotions.test.ts +172 -64
- package/src/__tests__/integration/gonogo.test.ts +183 -80
- package/src/__tests__/integration/nback.test.ts +148 -55
- package/src/__tests__/integration/spatial-cognition.test.ts +171 -66
- package/src/__tests__/test-utils/testData.ts +79 -79
- package/src/common-interfaces.ts +79 -0
- package/src/emotions.ts +98 -59
- package/src/getters.ts +21 -21
- package/src/gonogo.ts +126 -75
- package/src/index.ts +39 -23
- package/src/nback.ts +61 -53
- package/src/spatial-cognition.ts +112 -54
- package/tsconfig.cjs.json +12 -12
- package/tsconfig.esm.json +14 -14
|
@@ -1,81 +1,184 @@
|
|
|
1
|
-
import { gonogo_extract_trials, gonogo_results, gonogo_calculate_results } from '../../gonogo';
|
|
2
|
-
import { loadTestData } from '../test-utils/testData';
|
|
3
|
-
|
|
4
|
-
describe('Gonogo test module', () => {
|
|
5
|
-
// If gonogo data is available in your test data, load it
|
|
6
|
-
// const gonogoData = loadTestData('gonogo').gonogo;
|
|
7
|
-
|
|
8
|
-
const gonogoData = loadTestData('gonogo').gonogo;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
import { gonogo_extract_trials, gonogo_results, gonogo_calculate_results } from '../../gonogo';
|
|
2
|
+
import { loadTestData } from '../test-utils/testData';
|
|
3
|
+
|
|
4
|
+
describe('Gonogo test module', () => {
|
|
5
|
+
// If gonogo data is available in your test data, load it
|
|
6
|
+
// const gonogoData = loadTestData('gonogo').gonogo;
|
|
7
|
+
|
|
8
|
+
const gonogoData = loadTestData('gonogo').gonogo;
|
|
9
|
+
|
|
10
|
+
// Comprehensive mock data for predictable testing
|
|
11
|
+
const mockGonogoData = [
|
|
12
|
+
{
|
|
13
|
+
"trial_index": 8,
|
|
14
|
+
"block_number": 1,
|
|
15
|
+
"image": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/gonogo/aliens/astronaut_trans_1.png",
|
|
16
|
+
"rt": 1000,
|
|
17
|
+
"stimulus": "",
|
|
18
|
+
"response": 0,
|
|
19
|
+
"trial_type": "html-button-response",
|
|
20
|
+
"plugin_version": "2.0.0",
|
|
21
|
+
"time_elapsed": 15801,
|
|
22
|
+
"attempted": false
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"rt": null,
|
|
26
|
+
"stimulus": "<img src=\"https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/fixation_cross.png\" class=\"max-w-none\" style=\"display:none\" width=\"512\" height=\"512\" alt=\"Mapa\">",
|
|
27
|
+
"response": null,
|
|
28
|
+
"trial_type": "html-button-response",
|
|
29
|
+
"trial_index": 9,
|
|
30
|
+
"plugin_version": "2.0.0",
|
|
31
|
+
"time_elapsed": 16335,
|
|
32
|
+
"attempted": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"trial_index": 16,
|
|
36
|
+
"block_number": 1,
|
|
37
|
+
"image": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/gonogo/aliens/alien_trans_1.png",
|
|
38
|
+
"rt": null,
|
|
39
|
+
"stimulus": "",
|
|
40
|
+
"response": null,
|
|
41
|
+
"trial_type": "html-button-response",
|
|
42
|
+
"plugin_version": "2.0.0",
|
|
43
|
+
"time_elapsed": 20290,
|
|
44
|
+
"attempted": false
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"trial_index": 10,
|
|
48
|
+
"block_number": 1,
|
|
49
|
+
"image": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/gonogo/aliens/astronaut_trans_1.png",
|
|
50
|
+
"rt": null,
|
|
51
|
+
"stimulus": "",
|
|
52
|
+
"response": null,
|
|
53
|
+
"trial_type": "html-button-response",
|
|
54
|
+
"plugin_version": "2.0.0",
|
|
55
|
+
"time_elapsed": 16752,
|
|
56
|
+
"attempted": false
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"trial_index": 16,
|
|
60
|
+
"block_number": 1,
|
|
61
|
+
"image": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/gonogo/aliens/alien_trans_1.png",
|
|
62
|
+
"rt": 2000,
|
|
63
|
+
"stimulus": "",
|
|
64
|
+
"response": 0,
|
|
65
|
+
"trial_type": "html-button-response",
|
|
66
|
+
"plugin_version": "2.0.0",
|
|
67
|
+
"time_elapsed": 20290,
|
|
68
|
+
"attempted": false
|
|
69
|
+
},
|
|
70
|
+
// Non-gonogo data that should be filtered out
|
|
71
|
+
{ trial_type: 'instructions', text: 'Press space when...' },
|
|
72
|
+
{ trial_type: 'browser-check', browser: 'chrome' }
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
describe('gonogo_extract_trials', () => {
|
|
77
|
+
it('should extract trials from raw data', () => {
|
|
78
|
+
const trials = gonogo_extract_trials(gonogoData);
|
|
79
|
+
expect(trials.length).toBeLessThan(gonogoData.length);
|
|
80
|
+
|
|
81
|
+
trials.forEach(trial => {
|
|
82
|
+
expect(trial).toHaveProperty('stimulus');
|
|
83
|
+
expect(trial).toHaveProperty('stimulustype');
|
|
84
|
+
expect(trial).toHaveProperty('should_go');
|
|
85
|
+
expect(trial).toHaveProperty('did_go');
|
|
86
|
+
expect(trial).toHaveProperty('correct');
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should handle empty data array', () => {
|
|
91
|
+
const trials = gonogo_extract_trials([]);
|
|
92
|
+
expect(trials).toEqual([]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should extract mock data correctly', () => {
|
|
96
|
+
const trials = gonogo_extract_trials(mockGonogoData);
|
|
97
|
+
expect(trials.length).toBe(4); // Only trials with image field
|
|
98
|
+
|
|
99
|
+
// Check stimulus extraction and correctness logic
|
|
100
|
+
expect(trials[0].stimulus).toBe('astronaut_trans_1.png');
|
|
101
|
+
expect(trials[0].should_go).toBe(true); // astronaut in block 1
|
|
102
|
+
expect(trials[0].did_go).toBe(true); // response: 1
|
|
103
|
+
expect(trials[0].correct).toBe(true);
|
|
104
|
+
|
|
105
|
+
expect(trials[1].stimulus).toBe('alien_trans_1.png');
|
|
106
|
+
expect(trials[1].should_go).toBe(false); // alien in block 1
|
|
107
|
+
expect(trials[1].did_go).toBe(false); // response: null
|
|
108
|
+
expect(trials[1].correct).toBe(true);
|
|
109
|
+
|
|
110
|
+
expect(trials[2].stimulus).toBe('astronaut_trans_1.png');
|
|
111
|
+
expect(trials[2].should_go).toBe(true); // alien in block 1
|
|
112
|
+
expect(trials[2].did_go).toBe(false); // response: null
|
|
113
|
+
expect(trials[2].correct).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('gonogo_results', () => {
|
|
118
|
+
it('should calculate correct averages', () => {
|
|
119
|
+
const sampleTrials = [
|
|
120
|
+
{ rt: 500, correct: true, should_go: true, did_go: true },
|
|
121
|
+
{ rt: 600, correct: true, should_go: false, did_go: false },
|
|
122
|
+
{ rt: 700, correct: false, should_go: true, did_go: false },
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
const results = gonogo_results(sampleTrials);
|
|
126
|
+
console.log(results)
|
|
127
|
+
expect(results.common.n_trials).toBe(3);
|
|
128
|
+
expect(results.common.avg_rt_total).toBe(600); // (500 + 600 + 700) / 3
|
|
129
|
+
expect(results.common.n_correct_trials / results.common.n_trials).toBe(2/3); // (1 + 1 + 0) / 3
|
|
130
|
+
expect(results.common.performance_score).toBeGreaterThan(0);
|
|
131
|
+
expect(results.common.performance_score).toBeLessThanOrEqual(100);
|
|
132
|
+
expect(results).toHaveProperty('special');
|
|
133
|
+
expect(results.special).toHaveProperty('go_trials');
|
|
134
|
+
expect(results.special).toHaveProperty('nogo_trials');
|
|
135
|
+
expect(results.special).toHaveProperty('by_block');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('should handle empty trials array', () => {
|
|
139
|
+
expect(() => gonogo_results([])).toThrow();
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('should calculate mock data results correctly', () => {
|
|
143
|
+
const mockTrials = gonogo_extract_trials(mockGonogoData);
|
|
144
|
+
const mockResults = gonogo_results(mockTrials);
|
|
145
|
+
|
|
146
|
+
// Expected: 6 trials total, 6 correct, 0 incorrect, 2 missing
|
|
147
|
+
// (all trials are correct, but null responses still counted as missing)
|
|
148
|
+
expect(mockResults.common.n_trials).toBe(4);
|
|
149
|
+
expect(mockResults.common.n_correct_trials).toBe(2);
|
|
150
|
+
expect(mockResults.common.n_incorrect_trials).toBe(2);
|
|
151
|
+
|
|
152
|
+
expect(mockResults.common.avg_rt_total).toBe(1500);
|
|
153
|
+
|
|
154
|
+
// Expected avg_rt_correct: (500+600+400+700+800+0)/6 = 500 (all trials counted as correct)
|
|
155
|
+
expect(mockResults.common.avg_rt_correct).toBe(1000);
|
|
156
|
+
expect(mockResults.common.avg_rt_incorrect).toBe(2000);
|
|
157
|
+
|
|
158
|
+
// Performance score calculation using RT/(accuracy^5)
|
|
159
|
+
expect(mockResults.common.performance_score).toBeGreaterThanOrEqual(0);
|
|
160
|
+
expect(mockResults.common.performance_score).toBeLessThanOrEqual(100);
|
|
161
|
+
|
|
162
|
+
// Check special results
|
|
163
|
+
expect(mockResults.special.go_trials.n).toBe(2); // trials that should go
|
|
164
|
+
expect(mockResults.special.nogo_trials.n).toBe(2); // trials that should not go
|
|
165
|
+
expect(mockResults.special.by_block).toHaveLength(1); // 1 single block
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe('gonogo_calculate_results', () => {
|
|
170
|
+
it('should process raw data and return valid results', () => {
|
|
171
|
+
const results = gonogo_calculate_results(gonogoData);
|
|
172
|
+
console.log(results);
|
|
173
|
+
expect(results).toHaveProperty('common');
|
|
174
|
+
expect(results).toHaveProperty('special');
|
|
175
|
+
expect(results.common).toHaveProperty('n_trials');
|
|
176
|
+
expect(results.common).toHaveProperty('n_correct_trials');
|
|
177
|
+
expect(results.common).toHaveProperty('avg_rt_total');
|
|
178
|
+
expect(results.common).toHaveProperty('performance_score');
|
|
179
|
+
|
|
180
|
+
expect(results.common.performance_score).toBeGreaterThan(0);
|
|
181
|
+
expect(results.common.performance_score).toBeLessThanOrEqual(100);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
81
184
|
});
|
|
@@ -1,56 +1,149 @@
|
|
|
1
|
-
import { nback_extract_trials, nback_results,
|
|
2
|
-
nback_calculate_results
|
|
3
|
-
import { loadTestData } from '../test-utils/testData';
|
|
4
|
-
|
|
5
|
-
describe('N-Back Task Integration Tests', () => {
|
|
6
|
-
const testData = loadTestData('nback');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
import { nback_extract_trials, nback_results,
|
|
2
|
+
nback_calculate_results } from '../../nback';
|
|
3
|
+
import { loadTestData } from '../test-utils/testData';
|
|
4
|
+
|
|
5
|
+
describe('N-Back Task Integration Tests', () => {
|
|
6
|
+
const testData = loadTestData('nback');
|
|
7
|
+
|
|
8
|
+
// Mock data for predictable testing
|
|
9
|
+
const mockNbackData = [
|
|
10
|
+
{
|
|
11
|
+
"stimulus": "",
|
|
12
|
+
"trial_index": 25,
|
|
13
|
+
"nbackimage": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/nback//final/nback_final_fractals_4.png",
|
|
14
|
+
"is_target": false,
|
|
15
|
+
"rt": null,
|
|
16
|
+
"response": null,
|
|
17
|
+
"trial_type": "html-button-response",
|
|
18
|
+
"plugin_version": "2.0.0",
|
|
19
|
+
"time_elapsed": 70759,
|
|
20
|
+
"attempted": false,
|
|
21
|
+
"correct": true
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"stimulus": "",
|
|
25
|
+
"trial_index": 26,
|
|
26
|
+
"nbackimage": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/nback//final/nback_final_fractals_2.png",
|
|
27
|
+
"is_target": false,
|
|
28
|
+
"rt": null,
|
|
29
|
+
"response": null,
|
|
30
|
+
"trial_type": "html-button-response",
|
|
31
|
+
"plugin_version": "2.0.0",
|
|
32
|
+
"time_elapsed": 73325,
|
|
33
|
+
"attempted": false,
|
|
34
|
+
"correct": true
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"stimulus": "",
|
|
38
|
+
"trial_index": 27,
|
|
39
|
+
"nbackimage": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/nback//final/nback_final_fractals_4.png",
|
|
40
|
+
"is_target": true,
|
|
41
|
+
"rt": 1000,
|
|
42
|
+
"response": 0,
|
|
43
|
+
"trial_type": "html-button-response",
|
|
44
|
+
"plugin_version": "2.0.0",
|
|
45
|
+
"time_elapsed": 74928,
|
|
46
|
+
"attempted": false,
|
|
47
|
+
"correct": true
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"stimulus": "",
|
|
51
|
+
"trial_index": 28,
|
|
52
|
+
"nbackimage": "https://unyavwofnmwihnpvkjji.supabase.co/storage/v1/object/public/test-stimuli/nback//final/nback_final_fractals_3.png",
|
|
53
|
+
"is_target": false,
|
|
54
|
+
"rt": 2000,
|
|
55
|
+
"response": 0,
|
|
56
|
+
"trial_type": "html-button-response",
|
|
57
|
+
"plugin_version": "2.0.0",
|
|
58
|
+
"time_elapsed": 77512,
|
|
59
|
+
"attempted": false,
|
|
60
|
+
"correct": false
|
|
61
|
+
},
|
|
62
|
+
// Non-trial data that should be filtered out
|
|
63
|
+
{ trial_type: 'browser-check', browser: 'chrome' },
|
|
64
|
+
{ trial_type: 'instructions', text: 'Press space when...' }
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
describe('nback_extract_trials', () => {
|
|
68
|
+
it('should extract only trials with is_target field', () => {
|
|
69
|
+
const trials = nback_extract_trials(testData.nback);
|
|
70
|
+
expect(trials.every(trial => trial.is_target !== null)).toBe(true);
|
|
71
|
+
expect(trials.length).toBe(60);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should extract mock data correctly', () => {
|
|
75
|
+
const trials = nback_extract_trials(mockNbackData);
|
|
76
|
+
expect(trials.length).toBe(4); // Only trials with is_target field
|
|
77
|
+
expect(trials.every(trial => 'is_target' in trial)).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('nback_results', () => {
|
|
82
|
+
const trials = nback_extract_trials(testData.nback);
|
|
83
|
+
const results = nback_results(trials);
|
|
84
|
+
|
|
85
|
+
it('should calculate correct common metrics', () => {
|
|
86
|
+
expect(results.common).toHaveProperty('n_trials');
|
|
87
|
+
expect(results.common).toHaveProperty('n_correct_trials');
|
|
88
|
+
expect(results.common).toHaveProperty('n_incorrect_trials');
|
|
89
|
+
expect(results.common).toHaveProperty('avg_rt_total');
|
|
90
|
+
expect(results.common).toHaveProperty('avg_rt_correct');
|
|
91
|
+
expect(results.common).toHaveProperty('avg_rt_incorrect');
|
|
92
|
+
expect(results.common).toHaveProperty('performance_score');
|
|
93
|
+
expect(results.common.n_trials).toBeGreaterThan(0);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should calculate correct target trials metrics', () => {
|
|
97
|
+
expect(results.special.target_trials).toHaveProperty('n');
|
|
98
|
+
expect(results.special.target_trials).toHaveProperty('avg_rt');
|
|
99
|
+
expect(results.special.target_trials).toHaveProperty('avg_acc');
|
|
100
|
+
expect(results.special.target_trials.n).toBeGreaterThan(0);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('should calculate correct non-target trials metrics', () => {
|
|
104
|
+
expect(results.special.non_target_trials).toHaveProperty('n');
|
|
105
|
+
expect(results.special.non_target_trials).toHaveProperty('avg_rt');
|
|
106
|
+
expect(results.special.non_target_trials).toHaveProperty('avg_acc');
|
|
107
|
+
expect(results.special.non_target_trials.n).toBeGreaterThan(0);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should calculate performance score', () => {
|
|
111
|
+
expect(results.common.performance_score).not.toBeNaN();
|
|
112
|
+
expect(results.common.performance_score).toBeGreaterThanOrEqual(0);
|
|
113
|
+
expect(results.common.performance_score).toBeLessThanOrEqual(100);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('should calculate mock data results correctly', () => {
|
|
117
|
+
const mockTrials = nback_extract_trials(mockNbackData);
|
|
118
|
+
const mockResults = nback_results(mockTrials);
|
|
119
|
+
|
|
120
|
+
// Expected: 6 trials total, 4 correct, 2 incorrect, 1 missing (counting false as incorrect, not missing)
|
|
121
|
+
expect(mockResults.common.n_trials).toBe(4);
|
|
122
|
+
expect(mockResults.common.n_correct_trials).toBe(3);
|
|
123
|
+
expect(mockResults.common.n_incorrect_trials).toBe(1);
|
|
124
|
+
|
|
125
|
+
expect(mockResults.common.performance_score).toEqual(75);
|
|
126
|
+
|
|
127
|
+
expect(mockResults.common.avg_rt_total).toEqual(1500);
|
|
128
|
+
|
|
129
|
+
expect(mockResults.special.target_trials.n).toBe(1);
|
|
130
|
+
expect(mockResults.special.target_trials.avg_acc).toEqual(100);
|
|
131
|
+
|
|
132
|
+
expect(mockResults.special.non_target_trials.n).toBe(3);
|
|
133
|
+
expect(mockResults.special.non_target_trials.avg_acc).toBeCloseTo(66.67, 1);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe('nback_calculate_results', () => {
|
|
138
|
+
it('should calculate results correctly', () => {
|
|
139
|
+
const results = nback_calculate_results(testData.nback);
|
|
140
|
+
expect(results).toBeDefined();
|
|
141
|
+
expect(results).toHaveProperty('common');
|
|
142
|
+
expect(results).toHaveProperty('special');
|
|
143
|
+
expect(results.common).toHaveProperty('n_trials');
|
|
144
|
+
expect(results.common).toHaveProperty('performance_score');
|
|
145
|
+
expect(results.special).toHaveProperty('target_trials');
|
|
146
|
+
expect(results.special).toHaveProperty('non_target_trials');
|
|
147
|
+
});
|
|
148
|
+
});
|
|
56
149
|
});
|