这是我的代码片段:
let that = this;
console.log('is logged');
this.$translate.onReady().then(() => {
console.log('is ready - never logged');
that.$translate.refresh().then(() => console.log('DONE - never logged'));
});
在我的测试中,我尝试调用this.$translate.onReady()
以便记录console.log('is ready - never logged');
。反过来调用refresh()
。
我怎样才能做到这一点?
spyOn($translate, 'onReady').and.returnValue(
{
then:function() {
console.log('is logged');
}
});