Steve Gravrock
53d8073707
Allow generator functions to be passed to .and.callFake
...
Fixes #1848 .
2020-08-29 13:15:14 -07:00
Terence D. Honles
3943cc2ddb
allow spy throwError to throw an Object
...
When using the following code to simulate a node error:
spyOn(process, 'kill').and.throwError({code: 'ESRCH'})
The object passed in will be converted to a string by the Error
constructor and result in '[object Object]' which is not very useful.
This PR changes the ``throwError`` spy strategy to only convert
strings into an Error object, but any other objects which are passed
in will be thrown as is. This means the spy strategy can never emulate
throwing a bare string ``throw 'error'``, but this would be a backward
incompatible change.
2020-06-25 18:12:00 -07:00
Elliot Nelson
be3c8275d4
Tidy up SpyStrategy#exec
2020-02-06 10:34:55 -05:00
Elliot Nelson
bf4694333c
Improve wrapper function and parameter naming
2020-02-06 10:29:02 -05:00
Elliot Nelson
9febe3159d
Allow callThrough to call constructor functions without errors
2020-01-28 19:40:44 -05:00
Gregg Van Hove
15f969bee7
Add @since to most JSDoc comments
...
- See jasmine/jasmine.github.io#117
2019-06-12 16:23:12 -07:00
Gregg Van Hove
8af669677a
Cleanup spy promise strategies to be more consistent with Jasmine at large
...
- Rename `resolveWith` to `resolveTo` to match `toBeResolvedTo`
- No longer wrap non-Errors in `rejectWith`
- Fixes #1715
2019-05-23 17:29:12 -07:00
Gregg Van Hove
b4cbe9850f
add prettier and eslint
2019-05-21 18:23:48 -07:00
Elliot Nelson
b2fb92eedd
Promise-based strategies are now named resolveWith and rejectWith
2019-05-09 06:12:06 -04:00
Elliot Nelson
df818f3fbc
rejectValue wraps non-Errors like throwError does
2019-05-08 09:36:12 -04:00
Elliot Nelson
4731b4ee4d
Keep all Promise implementation details internal
2019-05-08 09:13:41 -04:00
Elliot Nelson
95e1890e64
Improved resolveValue/rejectValue error messages
2019-05-07 16:30:48 -04:00
Elliot Nelson
72aa0bbe4d
Add resolveValue and rejectValue spy strategies
2019-05-05 08:08:34 -04:00
Gregg Van Hove
f20f78f82b
Don't clobber previous custom plans with later plans
...
[finishes #37288941 ]
2018-01-22 12:10:24 -08:00
Steve Gravrock
4934e420b2
Allow adding custom spy strategies
...
[#37288941 ]
2018-01-10 08:59:19 -08:00
Steve Gravrock
16e07a0e99
Add the ability to specify the strategy to use for a spy based on which parameters are passed
...
[Finishes #92260826 ]
2018-01-03 08:49:34 -08:00
Steve Gravrock
2200dd084d
Fixed build
2017-12-01 08:34:12 -08:00
Gregg Van Hove
21655a82c9
Use prototype for spy strategy for better memory management
...
- Also convert `identity` to a property from a method
2017-11-30 17:30:20 -08:00
Julian Lannigan
2be5e0a962
Allowed async functions to be passed into spy#callFake
2017-11-09 19:59:23 -05:00
Gregg Van Hove
9cb2f06aa6
Add a first pass at jsdoc.
...
[##130415655] #596
2017-03-21 11:36:41 -07:00
Gregg Van Hove
4e47b78f1f
Use isFunction to check for functionness in callFake
...
- Fixes #1191
2016-09-14 16:06:44 -07:00
Andrzej Kopeć
bbf3f6825c
Improve error message when passing a non-function to callFake
2016-02-28 21:37:28 +01:00
slackersoft
bd30065d66
Merge branch 'chain_spy_andReturn' of https://github.com/mkhanal/jasmine into mkhanal-chain_spy_andReturn
2014-09-15 13:10:24 -07:00
Mridul
709e032d1c
Added returnValues functionality to spy strategy
2014-09-13 12:41:20 +10:00
Robin Böhm
31d71ac22f
add single quote check to jshint and fix src files for that
...
[fixes #522 ]
2014-02-24 16:28:16 -08:00
Sheel Choksi
4bff199c2a
Rename a spy's callReturn and callThrow
...
.and.callReturn is now .and.returnValue
.and.callThrow is now .and.throwError
[finishes #56281634 ]
2013-09-06 21:55:14 -07:00
Sheel Choksi
e3f0389ac2
Change andThrow to always throw an Error
...
If an error is passed in, it is thrown, otherwise the argument passed
in is wrapped in an Error
[finishes #50607615 ][closes #372 ]
2013-09-05 23:05:45 -07:00
Colin O'Byrne and JR Boyens
663a58d617
[Finishes #51528655 ] spies should support and.stub()
2013-07-22 14:39:06 -07:00
Davis W. Frank & Sheel Choksi
3847557bbc
Squashed spy refactor and new spy syntax
...
Jasmine spies now have a 'and' property which allows the user to
change the spy's execution strategy-- such as '.and.callReturn(4)'
and a 'calls' property which allows inspection of the calls a spy
has received.
* This is a breaking change *
There is a CallTracker that keeps track of all calls and arguments
and a SpyStrategy which determines what the spy should do when it
is called.
2013-07-22 14:29:52 -07:00