chext
Version:
CHrome EXtension Tester
56 lines (41 loc) • 1.17 kB
JavaScript
var environments = [
"chrome:http:",
"chrome:https:",
"chrome:chrome-extension:",
"chrome:chrome-extension:background:"
]
/**
* TestState object keeps track of passed browser tests. If an environment fails,
* it clears all results for a fresh round, if an environment passes, it keeps track
* if all environments have passed, TestState.allPassed is true.
*
**/
function TestState(){
this.results = {}
}
//return true if test is pass, false if fail, m
TestState.prototype.insert = function(testResult){
console.log("inserting test result", testResult.environment)
this.results[testResult.environment] = testResult;
this.checkAll();
}
TestState.prototype.checkAll = function(){
for (var i in environments){
console.log("env", environments[i])
if (!this.results[environments[i]])
return;
}
console.log("ALL PASSED")
this.complete = true;
}
TestState.prototype.All = function(){
return this.results;
}
TestState.prototype.clear = function(){
for (var i in environments){
this.results[environments[i]] = false;
}
this.complete = false;
console.log("tests cleared")
}
module.exports = new TestState();