Skip to content

Commit

Permalink
build: migration to pnpm+turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
tokebe committed Oct 18, 2023
1 parent 1691f63 commit dcd6b1b
Show file tree
Hide file tree
Showing 14 changed files with 5,420 additions and 566 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ typings/
# TypeScript cache
*.tsbuildinfo

# Turbo cache
.turbo

# Optional npm cache directory
.npm

Expand Down Expand Up @@ -105,4 +108,4 @@ dist

kevin.js

/built
/built
205 changes: 101 additions & 104 deletions __test__/base_transformer.test.ts
Original file line number Diff line number Diff line change
@@ -1,121 +1,118 @@
import {describe, expect, test} from '@jest/globals';

import base_tf from "../src/transformers/transformer";
import fs from "fs";
import path from "path";
import { JSONDoc } from '../src/json_transform/types';
import { JSONDoc } from "../src/json_transform/types";

describe("test base transformer", () => {
let response;
let input;

let response;
let input;

beforeEach(() => {
const response_path = path.resolve(__dirname, './data/ols/response.json');
response = JSON.parse(fs.readFileSync(response_path, { encoding: 'utf8' }));
const edge_path = path.resolve(__dirname, './data/ols/edge.json');
const edge = JSON.parse(fs.readFileSync(edge_path, { encoding: 'utf8' }));
input = {
response,
edge
}
})
beforeEach(() => {
const response_path = path.resolve(__dirname, "./data/ols/response.json");
response = JSON.parse(fs.readFileSync(response_path, { encoding: "utf8" }));
const edge_path = path.resolve(__dirname, "./data/ols/edge.json");
const edge = JSON.parse(fs.readFileSync(edge_path, { encoding: "utf8" }));
input = {
response,
edge,
};
});

test("Test pairInputWithAPIResponse function", () => {
const tf = new base_tf(input, {});
const res = tf.pairCurieWithAPIResponse();
expect(res).toHaveProperty("DOID:9562");
expect(res["DOID:9562"]).toHaveLength(1);
})
test("Test pairInputWithAPIResponse function", () => {
const tf = new base_tf(input, {});
const res = tf.pairCurieWithAPIResponse();
expect(res).toHaveProperty("DOID:9562");
expect(res["DOID:9562"]).toHaveLength(1);
});

test("Test wrap function if response is not an array", () => {
const tf = new base_tf(input, {});
const res = tf.wrap(response);
expect(res).toHaveProperty("_embedded");
})
test("Test wrap function if response is not an array", () => {
const tf = new base_tf(input, {});
const res = tf.wrap(response);
expect(res).toHaveProperty("_embedded");
});

test("Test wrap function if response is an array", () => {
const tf = new base_tf(input, {});
const fake = ["1"]
const res = tf.wrap(fake);
expect(res).toHaveProperty("data");
expect(res.data).toEqual(["1"])
})
test("Test wrap function if response is an array", () => {
const tf = new base_tf(input, {});
const fake = ["1"];
const res = tf.wrap(fake);
expect(res).toHaveProperty("data");
expect(res.data).toEqual(["1"]);
});

test("Test jsonTransform function", () => {
const tf = new base_tf(input, {});
const res: JSONDoc = tf.jsonTransform(response);
expect(res).toHaveProperty("has_subclass");
expect(res.has_subclass[0]).toHaveProperty("DOID");
expect(res.has_subclass[0].DOID).toEqual("DOID:0110596");
expect(res.has_subclass[0].name).toEqual("primary ciliary dyskinesia 21");
expect(res.has_subclass[0].description).toEqual([
"A primary ciliary dyskinesia that is characterized by autosomal recessive inheritance with a missing Nexin link, infantile onset of chronic sinopulmonary infections, and has_material_basis_in homozygous mutation in the DRC1 gene on chromosome 2p23."
]);
})
test("Test jsonTransform function", () => {
const tf = new base_tf(input, {});
const res: JSONDoc = tf.jsonTransform(response);
expect(res).toHaveProperty("has_subclass");
expect(res.has_subclass[0]).toHaveProperty("DOID");
expect(res.has_subclass[0].DOID).toEqual("DOID:0110596");
expect(res.has_subclass[0].name).toEqual("primary ciliary dyskinesia 21");
expect(res.has_subclass[0].description).toEqual([
"A primary ciliary dyskinesia that is characterized by autosomal recessive inheritance with a missing Nexin link, infantile onset of chronic sinopulmonary infections, and has_material_basis_in homozygous mutation in the DRC1 gene on chromosome 2p23.",
]);
});

test("Test _updatePublications function if pubmed id is prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmid: "PMID:1233"
}
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty('ref_pmid');
expect(res.publications).toEqual(["PMID:1233"]);
})
test("Test _updatePublications function if pubmed id is prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmid: "PMID:1233",
};
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty("ref_pmid");
expect(res.publications).toEqual(["PMID:1233"]);
});

test("Test _updatePublications function if pubmed id is NOT prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmid: 1233
}
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty('ref_pmid');
expect(res.publications).toEqual(["PMID:1233"])
})
test("Test _updatePublications function if pubmed id is NOT prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmid: 1233,
};
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty("ref_pmid");
expect(res.publications).toEqual(["PMID:1233"]);
});

test("Test _updatePublications function if pmc id is prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmcid: "PMCID:1233"
}
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty('ref_pmcid');
expect(res.publications).toEqual(["PMCID:1233"]);
})
test("Test _updatePublications function if pmc id is prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmcid: "PMCID:1233",
};
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty("ref_pmcid");
expect(res.publications).toEqual(["PMCID:1233"]);
});

test("Test _updatePublications function if pmc id is NOT prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmcid: 123
}
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty('ref_pmcid');
expect(res.publications).toEqual(["PMCID:123"])
})
test("Test _updatePublications function if pmc id is NOT prefixed", () => {
const tf = new base_tf(input, {});
const fake = {
ref_pmcid: 123,
};
const res = tf._updatePublications(fake);
expect(res).not.toHaveProperty("ref_pmcid");
expect(res.publications).toEqual(["PMCID:123"]);
});

test("Test extractObjectIDs function if output id type not in result", () => {
const tf = new base_tf(input, {});
const fake = {
kk: 1
};
const res = tf.extractObjectIDs(fake);
expect(res).toEqual([]);
})
test("Test extractObjectIDs function if output id type not in result", () => {
const tf = new base_tf(input, {});
const fake = {
kk: 1,
};
const res = tf.extractObjectIDs(fake);
expect(res).toEqual([]);
});

test("Test extractObjectIDs function if output id type is in result", () => {
const tf = new base_tf(input, {});
const fake = {
DOID: 1
};
const res = tf.extractObjectIDs(fake);
expect(res).toEqual(["DOID:1"]);
})
test("Test extractObjectIDs function if output id type is in result", () => {
const tf = new base_tf(input, {});
const fake = {
DOID: 1,
};
const res = tf.extractObjectIDs(fake);
expect(res).toEqual(["DOID:1"]);
});

test("Test formatRecords function if result is empty", async () => {
const tf = new base_tf(input, {});
const fake = {};
const res = await tf.formatRecords("NCBIGene:1017", fake);
expect(res).toEqual([]);
})
})
test("Test formatRecords function if result is empty", async () => {
const tf = new base_tf(input, {});
const fake = {};
const res = await tf.formatRecords("NCBIGene:1017", fake);
expect(res).toEqual([]);
});
});
Loading

0 comments on commit dcd6b1b

Please sign in to comment.