For a current application, I have a Generator class that is being fed with predefined data. The functionality to create a Generator is stored in the GeneratorMap object, and from there is is possible to build a Generator.
class Generator {
constructor(_generatorData) {
this._generatorData = _generatorData;
}
// ...
}
let GeneratorMap = {
_generatorMap: new Map([
[
'Generator-01', {
buildGenerator: function() {
// ...
}
}
]
]);
hasGenerator: function(uniqueName) {
return this._generatorMap.has(uniqueName);
}
getGenerator: function(uniqueName) {
return this._generatorMap.get(uniqueName).buildGenerator();
}
}
Now when I test the code, first I check whether all the required Generators are defined. Then I run each Generator through a forEach loop and test them. Is that the appropriate way to do so?
Aucun commentaire:
Enregistrer un commentaire