我正在使用一个选择器来检索一系列汽车,但是当我尝试测试时,我得到:
TypeError:agency.getCars 不是函数
describe('selectCars', () => {
it('should return car array', () => {
const stub = jasmine.createSpyObj<AgencyShop>({
findAgency: {
brand: 'BRAND_ID',
name: 'NAME'
getCars: () => ['Rio', 'Soul', 'Sportage']
} as Agency
});
const result = selectCars.projector(stub, {
brand: 'BRAND_ID'
});
expect(result).toEqual(['Rio', 'Soul', 'Sportage']);
});
模拟此功能的正确方法是什么。