-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with spies #35
Comments
To illustrate what I'm proposing: For now, I'm using a modified copy of this library in my test-suite, and just made this minimal change so I can finish. If you'd like, I'd be happy to go over the rest and submit a PR to make sure no methods are calling any public methods. (I supposed these methods could be |
@mindplay-dk I think we can just add internal helper methods that live off the class, like remove(parent, child). |
"Off the class", so not methods, just functions? Like this? function createEnvironment() {
// ...
function remove(parent, child) {
splice(parent.childNodes, child, false, true);
return child;
}
// ...
class Node {
// ...
removeChild(child) {
return remove(this, child);
}
remove() {
if (this.parentNode) remove(this.parentNode, this);
}
}
// ...
} |
I'm trying to spy on
removeChild
in a test - I have aparent
node being modified like this:To my surprise, it was counting way too many calls to
removeChild
.It turns out, several of these methods are being called internally, for brevity.
The real DOM does not call it's own public methods, afaik? If it needs to remove children for other reasons than calls to
removeChild
, it does not internally call the method, it just removed them.How would you feel about moving the internally reused methods to private methods?
The text was updated successfully, but these errors were encountered: