Как объявить и использовать интерфейсы в 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;
Ресурс:
Как объединить тестовая модель интерфейсов в машинописи?