I'm facing some confusion about receiving an undefined
as a return value for the function I am testing.
This is the function that I am currently testing:
$scope.entityItemsIntoObjectChecked = function (entityItems) {
newEntityWithChecked = entityItems.map(function (value) {
return { "val": value, "checked": false };
});
shareDataService.setEntityArray(newEntityWithChecked);
}
and here is a snippet from my test suite :
it("should arrange an array into object with extra values for entities + depots", inject(function (shareDataService) {
var dummyEntityArray = ["ent1", "ent2", "ent3"];
var expectedObjectArray = [{ val: "ent1", checked: false }, { val: 'ent2', checked: false }, { val: 'ent3', checked: false }];
expect(mainScope.entityItemsIntoObjectChecked).toBeDefined();
mainScope.entityItemsIntoObjectChecked(dummyEntityArray);
console.log(mainScope.entityItemsIntoObjectChecked(dummyEntityArray))
}))
I have been hoping to see my array displayed on the console based on the passed in array dummyEntityArray
, which was previously provided in the line
mainScope.entityItemsIntoObjectChecked(dummyEntityArray);
However, all I see is undefined
on the console log. Can anyone explain why this is happening?