Closed rjkroege closed 13 years ago
I wrote a possible patch for this issue and added a pull request for it.
I agree with this. This works well if we calls the mock in order. In NodeJS or with Ajax calls we might not be able to have a order of execution. That might be the worst case and we cannot address that. Do you have any say?
Hi,
On Sunday, June 12, 2011 at 10:34 PM, arunoda wrote:
I agree with this. This works well if we calls the mock in order. In NodeJS or with Ajax calls we might not be able to have a order of execution. That might be the worst case and we cannot address that. Do you have any say?
Sure. I think that a test author can want to verify two different properties with a method like mock.assert(): all indicated mock methods are executed the specified number of times but their order does not matter all indicated mock methods are executed in precisely the order specified
Further, one might want to group mocks so that the test can assert that some sub-set of mock methods are executed in the defined order while the others just need to have been called.
Since I writing mocks for a state-rich object with many side effects (DOM), order of calls mattered and I badly wanted to assert that they were being invoked in the correct order.
So, maybe the API could be augmented. Here's a suggestion:
var mock = nm.mock("foo").takes(1).startorderblock(); mock.mock("bar").takes(2); mock.mock("bar").takes(3).endorderblock(); mock.mock("foo").takes("yo");
mock.assert() would be true for: foo("yo"), foo(1), bar(2), bar(3) or foo(1), bar(2), bar(3), foo("yo")
Rob.
I think the current way is tolerable and we'll see any issues from others?
:)
On Mon, Jun 13, 2011 at 4:54 PM, rjkroege < reply@reply.github.com>wrote:
Hi,
On Sunday, June 12, 2011 at 10:34 PM, arunoda wrote:
I agree with this. This works well if we calls the mock in order. In NodeJS or with Ajax calls we might not be able to have a order of execution. That might be the worst case and we cannot address that. Do you have any say?
Sure. I think that a test author can want to verify two different properties with a method like mock.assert(): all indicated mock methods are executed the specified number of times but their order does not matter all indicated mock methods are executed in precisely the order specified
Further, one might want to group mocks so that the test can assert that some sub-set of mock methods are executed in the defined order while the others just need to have been called.
Since I writing mocks for a state-rich object with many side effects (DOM), order of calls mattered and I badly wanted to assert that they were being invoked in the correct order.
So, maybe the API could be augmented. Here's a suggestion:
var mock = nm.mock("foo").takes(1).startorderblock(); mock.mock("bar").takes(2); mock.mock("bar").takes(3).endorderblock(); mock.mock("foo").takes("yo");
mock.assert() would be true for: foo("yo"), foo(1), bar(2), bar(3) or foo(1), bar(2), bar(3), foo("yo")
Rob.
Reply to this email directly or view it on GitHub: https://github.com/arunoda/nodemock/issues/4#issuecomment-1358283
Arunoda Susiripala http://arunoda.com http://twitter.com/arunoda
On Monday, June 13, 2011 at 9:56 AM, arunoda wrote:
I think the current way is tolerable and we'll see any issues from others?
Sounds good to me.
Rob.
:)
On Mon, Jun 13, 2011 at 4:54 PM, rjkroege < reply@reply.github.com (mailto:reply@reply.github.com)>wrote:
Hi,
On Sunday, June 12, 2011 at 10:34 PM, arunoda wrote:
I agree with this. This works well if we calls the mock in order. In NodeJS or with Ajax calls we might not be able to have a order of execution. That might be the worst case and we cannot address that. Do you have any say?
Sure. I think that a test author can want to verify two different properties with a method like mock.assert(): all indicated mock methods are executed the specified number of times but their order does not matter all indicated mock methods are executed in precisely the order specified
Further, one might want to group mocks so that the test can assert that some sub-set of mock methods are executed in the defined order while the others just need to have been called.
Since I writing mocks for a state-rich object with many side effects (DOM), order of calls mattered and I badly wanted to assert that they were being invoked in the correct order.
So, maybe the API could be augmented. Here's a suggestion:
var mock = nm.mock("foo").takes(1).startorderblock(); mock.mock("bar").takes(2); mock.mock("bar").takes(3).endorderblock(); mock.mock("foo").takes("yo");
mock.assert() would be true for: foo("yo"), foo(1), bar(2), bar(3) or foo(1), bar(2), bar(3), foo("yo")
Rob.
Reply to this email directly or view it on GitHub: https://github.com/arunoda/nodemock/issues/4#issuecomment-1358283
Arunoda Susiripala http://arunoda.com http://twitter.com/arunoda
Reply to this email directly or view it on GitHub: https://github.com/arunoda/nodemock/issues/4#issuecomment-1358970
cool.
In the current version, there is no way to return different values from a single multiply-called mock. Example: