Angular jasmine spied Method toHaveBeenCalled的执行原理
生活随笔
收集整理的這篇文章主要介紹了
Angular jasmine spied Method toHaveBeenCalled的执行原理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
語法:expect(傳入一個被spied后的方法).matcher檢查
el.focus是spied method:
expect函數返回的是一個matcher:
進行toHaveBeenCalled的matcherFactory:
Expector原型鏈上的compare方法邏輯:首先生成一個matcher實例,然后使用apply的方式動態調用之:
spy函數的and屬性就是SpyStrategy,其Plan屬性返回的就是andReturnValue里指定的值。
calls屬性就是調用tracker.
expect(wrapped spied method)返回的expectation,是否通過,取決于toHaveBeenCalled方法里第735行:
只要calls里至少有一條記錄,expectation就算pass:
更多Jerry的原創文章,盡在:“汪子熙”:
總結
以上是生活随笔為你收集整理的Angular jasmine spied Method toHaveBeenCalled的执行原理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 银行卡挂失补办要钱吗 挂失补办银行卡要钱
- 下一篇: dnf红眼技能加点(地下城与勇士)