如何在 Angular Karma Jasmine 单元测试中声明和使用接口?以下给出错误,它说明接口的第一个属性未定义;试图让组件运行
无法读取未定义的“primaryPropertyMailingAddressId”的属性
业力/茉莉花:
beforeEach(async(() => {
fixture = TestBed.createComponent(PropertySitusFinalizeComponent);
component = fixture.componentInstance;
component.jsonData = {}; // removing or keeping this line does not change the error message
fixture.detectChanges();
}));
it('should create', () => {
expect(component).toBeTruthy();
});
零件:
export class PropertySitusFinalizeComponent implements OnInit {
@Input() jsonData: PropertySitusAddressContainer;
界面:
export interface PropertySitusAddressContainer {
queueItemId?: number;
existingPropertySitusAddress?: PropertySitusAddress;
export class PropertySitusAddress {
primaryPropertyMailingAddressId?:number = null;
propertyId?: number = null;
propertySitusAddressId?: number = null;
addressFormatId?: number = null;
apn?: string = null;
资源: