Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Nov 4, 2024
1 parent 7d09e2d commit c5258de
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
11 changes: 11 additions & 0 deletions arches_lingo/src/arches_lingo/fixtures/test_scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@
"narrower": []
}
]
},
{
"id": "080dc4fc-2533-418d-a794-1f871f416ab5",
"labels": [
{
"language_id": "en",
"value": "Other Top Concept",
"valuetype_id": "prefLabel"
}
],
"narrower": []
}
]
}
Expand Down
23 changes: 22 additions & 1 deletion arches_lingo/src/arches_lingo/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,31 @@ describe("Build scheme hierarchy", () => {
const schemeNode = nodes[0];
expect(schemeNode.label).toEqual("Test Scheme");
expect(schemeNode.iconLabel).toEqual("Scheme");
expect(schemeNode.data.top_concepts.length).toEqual(1);
expect(schemeNode.data.top_concepts.length).toEqual(2);

const topConcept = schemeNode.data.top_concepts[0];
expect(topConcept.labels[0].value).toEqual("Concept 1");
expect(topConcept.narrower.length).toEqual(4);
});
it("Should hide other top concepts when focusing child of another", () => {
const nodesBeforeFocus = treeFromSchemes(
schemesFixture["schemes"] as Scheme[],
ENGLISH,
ENGLISH,
iconLabels,
null,
);
const focusedNode = nodesBeforeFocus[0].children![0].children!.find(
(n) => n.data.labels[0].value === "Concept 2",
)!;
const nodesAfterFocus = treeFromSchemes(
schemesFixture["schemes"] as Scheme[],
ENGLISH,
ENGLISH,
iconLabels,
focusedNode,
);
const scheme = nodesAfterFocus[0];
expect(scheme.children!.length).toEqual(1);
});
});
7 changes: 5 additions & 2 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def setUpTestData(cls):

# Create a scheme with five concepts, each one narrower than the last,
# and each concept after the top concept also narrower than the top.
cls.scheme = ResourceInstance.objects.create(graph_id=SCHEMES_GRAPH_ID)
cls.scheme = ResourceInstance.objects.create(
graph_id=SCHEMES_GRAPH_ID, name="Test Scheme"
)

reference = DataTypeFactory().get_instance("reference")
language_config = {"controlledList": LANGUAGES_LIST_ID}
Expand All @@ -144,7 +146,8 @@ def setUpTestData(cls):
MAX_DEPTH = 5
CONCEPT_COUNT = 5
cls.concepts = [
ResourceInstance(graph_id=CONCEPTS_GRAPH_ID) for _ in range(CONCEPT_COUNT)
ResourceInstance(graph_id=CONCEPTS_GRAPH_ID, name=f"Concept {num + 1}")
for num in range(CONCEPT_COUNT)
]
for concept in cls.concepts:
concept.save()
Expand Down

0 comments on commit c5258de

Please sign in to comment.