aboutsummaryrefslogtreecommitdiff
path: root/test/unit/blob.unit.test.ts
blob: d0c4853c6a27392c75f4583f32e451e3c7d296bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Repository } from "server/src/git/repository";
import { Tree } from "server/src/git/tree";
import { EnvironmentVariables } from "../util";
import { Blob } from "server/src/git/blob";

const env = process.env as EnvironmentVariables;

describe("Blob", () => {
	describe("Class methods", () => {
		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.GIT_DIR, env.AVAIL_REPO));
			const blob = await Blob.fromPath(tree, "packages/client/src/main.ts");

			expect(blob).toBeDefined();
			expect(blob).toBeInstanceOf(Blob);
		});
	});

	describe("Instance methods", () => {
		let blob: Blob;

		beforeAll(async() => {
			const tree = await Tree.ofRepository(await Repository.open(env.GIT_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");
		});
	});
});