aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-07-26 17:36:02 +0200
committerHampusM <hampus@hampusmat.com>2021-07-26 17:36:02 +0200
commitc575df758b269db8e05c597d5870e948771d4c2b (patch)
tree7b247a1e47193ccbe187e09788a71c0c717ac575 /test
parenta737bc4695f99b05a3c4807c88fc30b1a1eb89b5 (diff)
Added a blob unit test & fixed the tree unit test
Diffstat (limited to 'test')
-rw-r--r--test/unit/blob.unit.test.ts36
-rw-r--r--test/unit/tree.unit.test.ts2
2 files changed, 37 insertions, 1 deletions
diff --git a/test/unit/blob.unit.test.ts b/test/unit/blob.unit.test.ts
new file mode 100644
index 0000000..efb7071
--- /dev/null
+++ b/test/unit/blob.unit.test.ts
@@ -0,0 +1,36 @@
+import { Repository } from "../../packages/server/src/git/repository";
+import { Tree } from "../../packages/server/src/git/tree";
+import { EnvironmentVariables } from "../util";
+import { Blob } from "../../packages/server/src/git/blob";
+
+const env = process.env as EnvironmentVariables;
+
+describe("Blob", () => {
+ it("Should the get a blob from a path in a tree", async() => {
+ expect.assertions(2);
+
+ const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO));
+ const blob = await Blob.fromPath(tree, "packages/client/src/main.ts");
+
+ expect(blob).toBeDefined();
+ expect(blob).toBeInstanceOf(Blob);
+ });
+
+ describe("Methods", () => {
+ let blob: Blob;
+
+ beforeAll(async() => {
+ const tree = await Tree.ofRepository(await Repository.open(env.BASE_DIR, env.AVAIL_REPO));
+ blob = await Blob.fromPath(tree, "packages/client/src/main.ts");
+ });
+
+ it("Should get the content", async() => {
+ expect.assertions(2);
+
+ const content = await blob.content();
+
+ expect(content).toBeDefined();
+ expect(typeof content).toEqual("string");
+ });
+ });
+}); \ No newline at end of file
diff --git a/test/unit/tree.unit.test.ts b/test/unit/tree.unit.test.ts
index 1658c35..f3ed635 100644
--- a/test/unit/tree.unit.test.ts
+++ b/test/unit/tree.unit.test.ts
@@ -42,7 +42,7 @@ describe("Tree", () => {
const entry = await tree.find("packages/server");
expect(entry).toBeDefined();
- expect(entry).toBeInstanceOf(Tree);
+ expect(entry).toBeInstanceOf(TreeEntry);
});
it("Should fail to return the entry of a nonexistent path", async() => {