aboutsummaryrefslogtreecommitdiff
path: root/test/unit/blob.unit.test.ts
blob: 308245a5d3e88ee5fff7d8a04f18c79acfd27c54 (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 "../../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", () => {
	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");
		});
	});
});