1
如何对使用window.localStorage的函数进行单元测试。下面是检查和创建localStorage的变量有两个功能:如何单元测试在Jasmine中使用window.localStorage的函数
// checks if Initial localStorage variable is true
// returns boolean
var isInitial = function() {
var doc = window.localStorage.getItem("Initial");
console.log("intial: " + doc);
if(doc !== "true"){
return true;
}
else{
return false;
}
};
// create InitialSync localStorage item and sets it to true
// void
var createInitial = function() {
console.log("creating Initial");
window.localStorage.setItem("Initial","true")
};
那么,什么是问题? –
重写了这个问题 –