mirror of
https://github.com/HeyPuter/puter.git
synced 2025-02-02 23:28:39 +08:00
34 lines
834 B
JavaScript
34 lines
834 B
JavaScript
module.exports = class TestFactory {
|
|
static cartesian (
|
|
name,
|
|
coverageModel,
|
|
{ each, init }
|
|
) {
|
|
const do_ = async t => {
|
|
const states = coverageModel.states;
|
|
|
|
if ( init ) await init(t);
|
|
|
|
for ( let i=0 ; i < states.length ; i++ ) {
|
|
const state = states[i];
|
|
|
|
if ( t.context.options.onlycase !== undefined ) {
|
|
if ( i !== t.context.options.onlycase ) {
|
|
continue;
|
|
}
|
|
}
|
|
|
|
await t.case(`case ${i}`, async () => {
|
|
console.log('state', state);
|
|
await each(t, state, i);
|
|
})
|
|
}
|
|
};
|
|
|
|
return {
|
|
name,
|
|
do: do_,
|
|
};
|
|
}
|
|
}
|