Closed dchambers closed 11 years ago
First, apologies for the long delay looking at this. JsMockito has been on hold for me for some time.
I'd like to merge in this pull request. However currently this causes several tests to fail. If you could fix those, then I'd be happy to release this change.
test:
[echo] Running test suite
[java] ...............................................................................................................................................................
[java] FAILED: when method invokedJsMockito object spy - should invoke method on proxied object
[java] TypeError: Cannot find function greeting in object [object Object].
[java]
[java]
[java] FAILED: when method invokedJsMockito object spy - should invoke method on proxied object with delegate as scope
[java] TypeError: Cannot find function greeting in object [object Object].
[java]
[java]
[java] FAILED: when method invoked with explicit scopeJsMockito object spy - should invoke method on proxied object with explicit scope
[java] TypeError: Cannot call method "call" of undefined
[java]
[java]
[java] FAILED: when method invoked with arguments matching stubwhen method stubbedJsMockito object spy - should return result of stub
[java] TypeError: Cannot find function greeting in object [object Object].
[java]
[java]
[java] FAILED: when method invoked with arguments matching stubwhen method stubbedJsMockito object spy - should not invoke the proxied object method
[java] TypeError: Cannot find function greeting in object [object Object].
[java]
[java]
[java] FAILED: when method invoked with arguments not matching stubwhen method stubbedJsMockito object spy - should invoke the proxied function
[java] TypeError: Cannot find function greeting in object [object Object].
[java]
[java]
[java] FAILED: when different method is invokedwhen method stubbedJsMockito object spy - should invoke the proxied function
[java] TypeError: Cannot find function greeting in object [object Object].
[java]
[java] .................
[java]
[java] 212 test(s), 7 failure(s)
[java] 3.133 seconds elapsed
[java] Java Result: 1
BUILD FAILED
I've realised that this is not a change I want in JsMockito. The tests are failing because it's now mocking the interface in the prototype object (of the constructor function) and not the interface of a constructed instance.
One must call mock() with a constructor function that requires no arguments, or with a fully instantiated object.
For reference, see #12.
Allow objects to be mocked without having to construct an instance of them.