All checks were successful
dev - build & deploy naar test / build-and-deploy (push) Successful in 39s
74 lines
3.7 KiB
JavaScript
74 lines
3.7 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import {readFile} from 'node:fs/promises';
|
|
import {runInNewContext} from 'node:vm';
|
|
|
|
async function progressionContext(){
|
|
const source=await readFile('public/js/learning-progressions.js','utf8');
|
|
const pure=source.slice(0,source.indexOf('(function registerOwnLearningLevelSettings'));
|
|
const context={LANG:'nl'};
|
|
runInNewContext(pure+`
|
|
;globalThis.__profiles=LEARNING_YEAR_PROFILES;
|
|
globalThis.__languageWordsForYear=languageWordsForYear;
|
|
globalThis.__languageTaskRules=languageTaskRules;
|
|
globalThis.__mathTaskRules=mathTaskRules;
|
|
`,context);
|
|
return context;
|
|
}
|
|
|
|
test('taal en rekenen hebben een compleet inhoudelijk profiel voor groep 1 tot en met 8',async()=>{
|
|
const {__profiles:profiles}=await progressionContext();
|
|
for(const subject of ['taal','rekenen']){
|
|
assert.equal(profiles[subject].length,9);
|
|
for(let year=1;year<=8;year++){
|
|
const profile=profiles[subject][year];
|
|
assert.ok(profile.phase&&profile.title,subject+' groep '+year);
|
|
assert.equal(profile.goals.length,3,subject+' groep '+year+' heeft drie concrete accenten');
|
|
}
|
|
}
|
|
});
|
|
|
|
test('taalprofiel selecteert eenvoudiger woorden in de onderbouw en bouwt taaksteun af',async()=>{
|
|
const c=await progressionContext();
|
|
const words=[['kat','x'],['vis','x'],['pen','x'],['maan','x'],['boek','x'],['fiets','x'],
|
|
['brandweerauto','x'],['onderzoeker','x'],['verantwoordelijkheid','x']];
|
|
const early=JSON.parse(JSON.stringify(c.__languageWordsForYear(words,2,2)));
|
|
const late=JSON.parse(JSON.stringify(c.__languageWordsForYear(words,8,2)));
|
|
assert.ok(early.length<late.length);
|
|
assert.ok(early.every(([word])=>!['brandweerauto','verantwoordelijkheid'].includes(word)));
|
|
assert.equal(c.__languageTaskRules(2,2).flashSeconds,3);
|
|
assert.equal(c.__languageTaskRules(7,2).flashSeconds,.5);
|
|
assert.ok(c.__languageTaskRules(2,2).lives>c.__languageTaskRules(7,2).lives);
|
|
});
|
|
|
|
test('rekenprofiel vergroot getalgebied, tafels en breuken per leerjaar',async()=>{
|
|
const c=await progressionContext();
|
|
assert.equal(c.__mathTaskRules(2,3).addSub,20);
|
|
assert.equal(c.__mathTaskRules(3,1).timesTable,2);
|
|
assert.equal(c.__mathTaskRules(3,3).timesTable,10);
|
|
assert.equal(c.__mathTaskRules(4,3).addSub,100);
|
|
assert.equal(c.__mathTaskRules(6,3).addSub,10000);
|
|
assert.equal(c.__mathTaskRules(1,2).fractionDen,2);
|
|
assert.equal(c.__mathTaskRules(8,3).fractionDen,12);
|
|
assert.deepEqual(JSON.parse(JSON.stringify(c.__mathTaskRules(3,2).clockMinutes)),[0,15,30,45]);
|
|
});
|
|
|
|
test('alle taal- en rekenwidgets ontvangen de centrale leerjaarstate en tonen het profiel',async()=>{
|
|
const [html,board,pupil,progressions,letters,flits,hak,ball,math,numberline,learning]=await Promise.all([
|
|
readFile('public/index.html','utf8'),readFile('public/js/board.js','utf8'),
|
|
readFile('public/js/pupil.js','utf8'),readFile('public/js/learning-progressions.js','utf8'),
|
|
...['letters','flits','hak','ball','math','numberline','learning'].map(name=>readFile('public/js/widgets/'+name+'.js','utf8')),
|
|
]);
|
|
assert.ok(html.indexOf('js/data.js')<html.indexOf('js/learning-progressions.js'));
|
|
assert.ok(html.indexOf('js/learning-progressions.js')<html.indexOf('js/widgets/letters.js'));
|
|
assert.match(board,/learningStateForWidget/);
|
|
assert.match(pupil,/applyLearningLevelToState/);
|
|
assert.match(pupil,/appendLearningProfileBadge/);
|
|
assert.match(progressions,/managedLearningLevel/);
|
|
for(const source of [letters,flits,hak,ball])assert.match(source,/languageWordsForYear/);
|
|
assert.match(math,/mathTaskRules/);
|
|
assert.match(numberline,/mathTaskRules/);
|
|
for(const mount of ['mountFractions','mountClock','mountPlacevalue','mountMoney','mountWordtypes']){
|
|
assert.ok(learning.includes('function '+mount),mount);
|
|
}
|
|
});
|