-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathex10.js
More file actions
32 lines (19 loc) · 834 Bytes
/
ex10.js
File metadata and controls
32 lines (19 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
SPY
Override a specified method of an object with new functionality while still maintaining all of the old behaviour.
Create a spy that keeps track of how many times a function is called.
## Example
var spy = Spy(console, 'error')
console.error('calling console.error')
console.error('calling console.error')
console.error('calling console.error')
console.log(spy.count) // 3
## Arguments
* target: an object containing the method `method`
* method: a string with the name of the method on `target` to spy on.
## Conditions
* Do not use any for/while loops or Array#forEach.
* Do not create any unnecessary functions e.g. helpers.
## Hint
* Functions have context, input and output. Make sure you consider the context, input to *and output from* the function you are spying on.
*/