I've seen this question a lot but have yet to find an answer. I have an angular service I want to test that handles Undo\Redo. Here it is:
function UndoRedoService() {
var undoStack = [], redoStack = [];
this.add = function add(cmd) {
undoStack.push(cmd);
};
}
I want to test this method. In my test I want to be able to access the undoStack size. I don't want to extract it to another service since that would be an overkill. On the other hand, I don't want to make it public by adding it to "this."
Is there any way I can access this variable? I've tried monkey patching but couldn't access it like that either...
I'd appreciate any answer that isn't: "You shouldn't be testing local variable values"
Thanks! Uri
Aucun commentaire:
Enregistrer un commentaire