gpt4 book ai didi

javascript - Jasmine 监视嵌套对象

转载 作者:可可西里 更新时间:2023-11-01 02:54:08 26 4
gpt4 key购买 nike

我的服务对象是这样的:

var appService = {
serviceOne: {
get: function(){}
},
serviceTwo: {
query: function(){}
}
}

我想模拟 appService,像这样:

expect(appService.serviceTwo.query).toHaveBeenCalled();

我该怎么做?

最佳答案

好的,我得到了这个工作:

appService: {
serviceOne: jasmine.createSpyObj('serviceOne', ['get']),
serviceTwo: jasmine.createSpyObj('serviceTwo', ['query'])
}

我希望这是正确的做法。

关于javascript - Jasmine 监视嵌套对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17120921/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com