【发布时间】:2020-05-20 12:12:51
【问题描述】:
我遇到以下测试错误:
✖ 应该创建 铬 81.0.4044 (Mac OS X 10.14.6) TypeError:无法读取未定义的属性“管道” 在 AccountsInfoComponent.loadCompanyTypes (webpack:///./src/app/contacts/contact/overview/accounts-info/accounts-info.component.ts?:75:13) 在 AccountsInfoComponent.initAccountsInfoForm (webpack:///./src/app/contacts/contact/overview/accounts-info/accounts-info.component.ts?:129:14) 在 AccountsInfoComponent.updateContactAccounts (webpack:///./src/app/contacts/contact/overview/accounts-info/accounts-info.component.ts?:89:22) 在 AccountsInfoComponent.set [作为联系人] (webpack:///./src/app/contacts/contact/overview/accounts-info/accounts-info.component.ts?:47:18) 在 UserContext.eval (webpack:///./src/app/contacts/contact/overview/accounts-info/accounts-info.component.spec.ts?:120:27)
我有一个使用这种方法的服务:
getCompanyType(contact_id: string) {
const url = `api/v1/contact/sponsors_list?contact_id=${contact_id}`
return this.http.get<any>(url)
}
还有一个使用这种方法的组件:
loadCompanyTypes() {
this.editService
.getCompanyType(this.contact.id)
.pipe(untilDestroyed(this))
.subscribe(classic_where_held => {
const arrayOfTypes = classic_where_held.where_held_classic_id
this.companyTypes = arrayOfTypes.map(x => {
return { classic_id: x[0], name: x[1] }
})
})
}
我在测试中模拟了我的服务方法:
const mockContactEditService = {
addEditSection: jasmine.createSpy('addEditSection'),
setSaveUpdateContact: jasmine.createSpy('addEditSection'),
getCompanyType: jasmine.createSpy('getCompanyType')
}
测试在这里中断.pipe(untilDestroyed(this)) 它说 getCompanyType 没有返回任何内容,它应该返回一个 Observable???
【问题讨论】:
标签: angular