aboutsummaryrefslogtreecommitdiff
path: root/test/unit/blob.unit.test.ts
blob: efb7071ac282251aea69089a25f7617b6d23fab7 (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
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");
		});
	});
});