Possibly a naive question but I have a class similar to(mine has more data read from database and caching them):
var genericClass = class {
constructor() {
this.genericStructure = {};
}
async getState(key) {
//some more core logic
return this.genericStructure[key];
}
async putState(key, genericJson) {
this.genericStructure[key] = genericJson;
return true;
}
}
its getState and putState are used multiple times in a consumer class, I want to mock all these occurences from a local map object in my test class. Can it be done?
I am using chai, mocha, sinon
"devDependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^4.19.1",
"mocha": "^5.2.0",
"nyc": "^12.0.2",
"sinon": "^6.0.0",
"sinon-chai": "^3.2.0"
}