refactor: find i.p.v. filter

This commit is contained in:
Tibo De Peuter 2025-03-23 13:07:10 +01:00
parent 293c51bab3
commit ac10518cb8
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
4 changed files with 10 additions and 8 deletions

View file

@ -21,7 +21,7 @@ export function expectToBeCorrectEntity<T extends object>(actual: { entity: T; n
}
for (const property in expected.entity) {
if (
property! in IGNORE_PROPERTIES &&
property in IGNORE_PROPERTIES &&
expected.entity[property] !== undefined && // If we don't expect a certain value for a property, we assume it can be filled in by the database however it wants.
typeof expected.entity[property] !== 'function' // Functions obviously are not persisted via the database
) {
@ -136,10 +136,10 @@ export function expectToBeCorrectLearningPath(
version: node.version,
};
expect(expectedLearningPathNodes.keys()).toContainEqual(nodeKey);
const expectedNode = [...expectedLearningPathNodes.entries()].filter(
const expectedNode = [...expectedLearningPathNodes.entries()].find(
([key, _]) => key.learningObjectHruid === nodeKey.learningObjectHruid && key.language === node.language && key.version === node.version
)[0][1];
expect(node.start_node).toEqual(expectedNode?.startNode);
)![1];
expect(node.start_node).toEqual(expectedNode.startNode);
expect(new Set(node.transitions.map((it) => it.next.hruid))).toEqual(
new Set(expectedNode.transitions.map((it) => it.next.learningObjectHruid))