Я хочу проверить функцию, и у меня возникла проблема с проверкой типа.
Я получаю следующую ошибку:
Аргумент типа «TestDates []» не может быть назначен для параметра типа сегодня «TestDates'.Property„“отсутствует в типе„TestDates []“.
Как я могу это решить?
it('should create the table', () => {
const testDataMock = new DataItems([new TestDates(new Date(), new Date(), new Date())],
[new DataTable('123456', date, 1.05728,
undefined, -0.123, -0.123)]
);
const spy = spyOn(component, 'createTable');
component.createMatrixTable(testDataMock);
fixture.detectChanges();
expect(spy).toHaveBeenCalled();
});
TestDates
export class TestDates {
constructor(public today: Date,
public lastMonth: Date,
public lastDay: Date) {
}
}
createMatrixTable
createMatrixTable(items: DataItems) {
const {lastDay, lastMonth, today} = items.dateValues[0];
const spreadOrQuote = this.data.type === 1 ? 'in' : 'out';
this.createTable(items, columns);
}
После пробного запуска я получаю следующее сообщение:
TypeError: Невозможно прочитать свойство 'lastDay' из неопределенного