我想模拟这个接口,并且只模拟单个属性。
代码:
interface TheService
{
[index: number]: any;
...
}
测试
let theService: jasmine.SpyObj<TheService>;
beforeEach(() => {
theService = jasmine.createSpyObj<TheService>('theService', [0]);
});
it('does something', () => {
theService[0].and.returnValue({ dummy: 'test'});
...
console.log(theService[0].dummy); // here I want to print "test"
});
这有可能在茉莉花中嘲笑索引器吗?