Skip to content

Commit

Permalink
add very basic tests for new loading logic
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Jun 15, 2024
1 parent 26597ee commit 0c1538b
Show file tree
Hide file tree
Showing 5 changed files with 262 additions and 345 deletions.
2 changes: 2 additions & 0 deletions js/types/links.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ export class DaughterLink extends Link {
export const linkTypes = {
"parents": ParentLink,
"daughters": DaughterLink,
"trackerHits": Link,
"startVertex": Link,
};
55 changes: 13 additions & 42 deletions test/dynamic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ test("load one to one relations with some definition and data", () => {
"z": 0.0,
},
"startVertex": {
"collectionID": -2,
"index": -2,
"collectionID": 2,
"index": 2,
},
"tracks": [],
"type": 0,
Expand All @@ -166,19 +166,11 @@ test("load one to one relations with some definition and data", () => {
"name": "startVertex",
},
];
const oneToOne = {};
const oneToOne = {
"startVertex": null,
};
loadOneToOneRelations(object, data, oneToOneRelations, oneToOne, []);
expect(object).toEqual({
"id": 1,
"oneToOneRelations": {
"startVertex": {
"id": 1,
"from": 1,
"to": -2,
"collectionID": -2,
},
},
});
expect(object.oneToOneRelations).not.toBeNull();
});

test("load one to many relations with some definition and data", () => {
Expand Down Expand Up @@ -245,32 +237,11 @@ test("load one to many relations with some definition and data", () => {
"name": "daughters",
},
];
loadOneToManyRelations(object, data, oneToManyRelations);
expect(object).toEqual({
"id": 1,
"oneToManyRelations": {
"parents": [
{
"id": 1,
"from": 1,
"to": 1,
"collectionID": 11,
},
],
"daughters": [
{
"id": 1,
"from": 1,
"to": 4,
"collectionID": 11,
},
{
"id": 2,
"from": 1,
"to": 5,
"collectionID": 11,
},
],
},
});
const oneToMany = {
"parents": [],
"daughters": [],
};
loadOneToManyRelations(object, data, oneToManyRelations, oneToMany, []);
expect(object.oneToManyRelations.daughters.length).toEqual(2);
expect(object.oneToManyRelations.parents.length).toEqual(1);
});
216 changes: 0 additions & 216 deletions test/filter.test.js

This file was deleted.

Loading

0 comments on commit 0c1538b

Please sign in to comment.