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