Skip to content

Commit 4a2cb4c

Browse files
committed
Tests: Changed taxonomy manager test to use full sample file
- Taxonomy manager test now loads the `taxonomy.yml` file from the tests folder and checks output against a snapshot.
1 parent 37dbcaf commit 4a2cb4c

File tree

2 files changed

+20
-37
lines changed

2 files changed

+20
-37
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`The TaxonomyManager should load an Odin taxonomy (yaml string) 1`] = `"[\\"Alias\\",\\"ModificationTrigger\\",\\"Site\\",{\\"Context\\":[\\"Species\\",\\"CellLine\\",\\"Organ\\",\\"CellType\\",\\"Cellular_component\\",\\"TissueType\\",\\"ContextDirection\\",\\"ContextLocation\\",\\"ContextPossessive\\"]},{\\"Modification\\":[\\"PTM\\",{\\"Mutant\\":[\\"GenericMutant\\",\\"SubstitutionMutant\\",\\"DeletionMutant\\",\\"DuplicationMutant\\",\\"InsertionMutant\\",\\"FrameshiftMutant\\"]},\\"EventSite\\",\\"Negation\\"]},{\\"PossibleController\\":[{\\"Event\\":[{\\"SimpleEvent\\":[\\"Binding\\",\\"Generic_event\\",\\"Translocation\\",{\\"Amount\\":[{\\"IncreaseAmount\\":[\\"Transcription\\"]},\\"DecreaseAmount\\"]},{\\"AdditionEvent\\":[\\"Acetylation\\",\\"Farnesylation\\",\\"Glycosylation\\",\\"Hydrolysis\\",\\"Hydroxylation\\",\\"Methylation\\",{\\"Phosphorylation\\":[\\"AutoPhosphorylation\\"]},\\"Ribosylation\\",\\"Sumoylation\\",\\"Ubiquitination\\"]},{\\"RemovalEvent\\":[\\"Deacetylation\\",\\"Defarnesylation\\",\\"Deglycosylation\\",\\"Dehydrolysis\\",\\"Dehydroxylation\\",\\"Demethylation\\",\\"Dephosphorylation\\",\\"Deribosylation\\",\\"Desumoylation\\",\\"Deubiquitination\\"]}]},{\\"ComplexEvent\\":[{\\"Regulation\\":[\\"Positive_regulation\\",\\"Negative_regulation\\"]},{\\"ActivationEvent\\":[\\"Positive_activation\\",\\"Negative_activation\\"]}]}]},{\\"Entity\\":[{\\"BioEntity\\":[\\"BioProcess\\",{\\"BioChemicalEntity\\":[\\"Generic_entity\\",\\"Simple_chemical\\",{\\"Equivalable\\":[\\"Family\\",{\\"MacroMolecule\\":[\\"Protein\\",\\"Gene_or_gene_product\\",\\"Complex\\",\\"GENE\\"]}]}]}]}]}]},{\\"Precedence\\":[\\"DirectConnection\\",\\"IndirectConnection\\",{\\"BetweenSentence\\":[\\"TimexAfter\\",\\"TimexBefore\\",\\"SentenceInitialEvent\\",\\"InterAfter\\",\\"InterBefore\\"]},{\\"TAM\\":[\\"Aux\\",{\\"Tense\\":[\\"PastTense\\",\\"PresentTense\\",\\"FutureTense\\"]},{\\"Aspect\\":[\\"Perfective\\",\\"Progressive\\"]}]}]}]"`;
Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,25 @@
11
/**
2-
* Test taxonomy manager
3-
*/
2+
* Test taxonomy manager
3+
*/
44

5-
//import * as fs from "fs";
6-
7-
// JS-YAML library
8-
//import * as yaml from "js-yaml";
5+
import * as fs from "fs";
96

107
import TaxonomyManager from "../js/managers/taxonomy.js";
118
import Config from "../js/config.js";
129

1310
describe("The TaxonomyManager", () => {
14-
it("should load an Odin taxonomy (yaml string)", () => {
15-
16-
// Pull the sample taxonomy file
17-
//const yamlData = fs.readFileSync("./src/__tests__/data/taxonomy.yml", "utf8");
18-
19-
const yamlData = `
20-
- Alias
21-
- ModificationTrigger
22-
- Site
23-
- Context:
24-
- Species
25-
- CellLine
26-
- Organ
27-
- CellType
28-
- Cellular_component
29-
- TissueType
30-
- ContextDirection
31-
- ContextLocation
32-
- ContextPossessive
33-
`
34-
const conf = new Config();
35-
36-
// Initialize TaxonomyManager and load data
37-
const taxman = new TaxonomyManager(conf);
38-
39-
taxman.loadTaxonomyYaml(yamlData);
40-
41-
const tree = taxman.getTaxonomyTree();
42-
43-
expect(tree[0]).toBe("Alias");
44-
});
11+
it("should load an Odin taxonomy (yaml string)", () => {
12+
const yamlData = fs.readFileSync("./src/__tests__/data/taxonomy.yml", "utf8");
13+
14+
const conf = new Config();
15+
16+
// Initialize TaxonomyManager and load data
17+
const taxman = new TaxonomyManager(conf);
18+
19+
taxman.loadTaxonomyYaml(yamlData);
20+
21+
const tree = taxman.getTaxonomyTree();
22+
23+
expect(JSON.stringify(tree)).toMatchSnapshot();
24+
});
4525
});

0 commit comments

Comments
 (0)