(method, matchAny, actual, notCalled)
| 1723 | }; |
| 1724 | |
| 1725 | function delegateToCalls(method, matchAny, actual, notCalled) { |
| 1726 | spyApi[method] = function () { |
| 1727 | if (!this.called) { |
| 1728 | if (notCalled) { |
| 1729 | return notCalled.apply(this, arguments); |
| 1730 | } |
| 1731 | return false; |
| 1732 | } |
| 1733 | |
| 1734 | var currentCall; |
| 1735 | var matches = 0; |
| 1736 | |
| 1737 | for (var i = 0, l = this.callCount; i < l; i += 1) { |
| 1738 | currentCall = this.getCall(i); |
| 1739 | |
| 1740 | if (currentCall[actual || method].apply(currentCall, arguments)) { |
| 1741 | matches += 1; |
| 1742 | |
| 1743 | if (matchAny) { |
| 1744 | return true; |
| 1745 | } |
| 1746 | } |
| 1747 | } |
| 1748 | |
| 1749 | return matches === this.callCount; |
| 1750 | }; |
| 1751 | } |
| 1752 | |
| 1753 | delegateToCalls("calledOn", true); |
| 1754 | delegateToCalls("alwaysCalledOn", false, "calledOn"); |
no outgoing calls
no test coverage detected
searching dependent graphs…