-
Notifications
You must be signed in to change notification settings - Fork 375
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
Add Unique ID to all mock handlers? #184
Comments
Possibly – but I wonder if a more traditional approach could be used. For instance, each mock would get a lightweight instance wrapper that is returned instead of a number when |
Ooooooooh, yes. I like that idea. Returning a wrapper with a couple helper methods. Let me think on this and I'll suggest a format in here. |
What all could be included here? var mock = $.mockjax({
url: '/foo'
});
mock.id; // 12345
mock.options; // { /* ... */ }
mock.destroy(); |
I would argue that we make it mostly functions versus properties, that way we can change implementations later. But what you have so far is a good start: var mock = $.mockjax({ ... });
mock.getId();
mock.getSettings();
mock.clear(); // versus "destroy", this keeps it in line with $.mockjax.clear()
mock.callCount(); // we already have this info sorta... just have to access it That's all i can think of right now. |
returning a wrapper would be really handy 😁 |
I realise my message was too concise, the wrapper should also include a |
Great idea! I'm super busy on other things right now, but I'd like to implement this at some point. It needs to be done carefully, however, so that it doesn't break existing code (if possible). |
changing the return value of
a bit ugly 😁 |
I'm wondering if we should assign a proper ID to each mock handler. Currently this is just the index in the array of handlers, but that seems fragile. Having proper IDs would still allow clearing individual requests or all handlers, but would eliminate the possibility of the calling code holding onto that index past when it should, then trying to use it and clearing a mock handler that it did not intend to.
Any thoughts @dcneiner or @jcreamer898 (or anyone else)?
The text was updated successfully, but these errors were encountered: