Here's a function that I have:
updateParts(enviromentContainsAllParts: PartsContainsAllParts): Observable<boolean> {
const enviroment = cloneDeep(this.enviroment);
enviroment.containsAllPart = enviromentContainsAllParts.containsAllPart;
for (let index = 0; index < enviromentContainsAllParts.parts.length; index++) {
const currentPart = enviromentContainsAllParts.parts[index];
enviroment.parts.push({
size: currentPart.sizeOfEnviroment
});
}
return of(true);
}
When attempting to unit test this function:
it('should have changed the environment parts', () => {
// GIVEN
const enviroment = cloneDeep(fakeCurrentEnvironment);
service.environment = environment;
// WHEN
service.updateParts(building).subscribe(data =>
expect(data).toBeTruthy()
);
// THEN
});
An error was encountered:
TypeError: Cannot read property 'length' of undefinedCan anyone help me identify what I might be doing wrong?