We need to provide a basic object that can be used as a spy to ensure that methods are called/called with the correct arguments. Then we should write matchers to make assertions about Spy objects easier.
class Spy {
new (name) {
_name = name
_calls = []
}
new (name, return_value) {
_name = name
_return_value = return_value
_calls = []
}
calls { _calls }
call {
_calls.add([])
return _return_value
}
call (one) {
_calls.add([one])
return _return_value
}
// up to 16 arguments...
}
We need to provide a basic object that can be used as a spy to ensure that methods are called/called with the correct arguments. Then we should write matchers to make assertions about Spy objects easier.