I don't have so much experience with Jest and I have some issues testing the following javascript method:
const parseResults = (items) => {
const results = [];
const itemsLength = items.length;
for (let i = 0; i < itemsLength; i += 1) {
const element = items[i];
if (element.status === "fulfilled") {
if (Array.isArray(element.value)) {
results.push(...element.value);
} else {
results.push(element.value);
}
} else {
logger.error(`${element.reason}`);
}
}
return results;
};
and so far, my test is this:
describe("parseResults", () => {
it("should ", () => {
const items = [{ element: "status", value: "testValue" }];
const result = parseResultsAndErrors(items);
expect(result).toBe();
});
});
On Received it gives me an empty []. I think something is wrong here.. anyone knows how to write this test and how should I write the expect ?