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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
import { BaseTreeEntry, BlobTreeEntry, TreeEntry } from "server/src/git/tree_entry";
import { Repository } from "server/src/git/repository";
import { EnvironmentVariables } from "../util";
import { Commit } from "server/src/git/commit";
import { Tree } from "server/src/git/tree";
import { Blob } from "../../packages/server/src/git/blob";
const env = process.env as EnvironmentVariables;
describe("Tree entry", () => {
describe("Base tree entry", () => {
describe("Class methods", () => {
let tree_entry: BaseTreeEntry;
beforeAll(async() => {
const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
const tree = await repository.tree();
tree_entry = tree.entries()[0];
});
it("Should get the latest commit", async() => {
expect.assertions(2);
const latest_commit = await tree_entry.latestCommit();
expect(latest_commit).toBeDefined();
expect(latest_commit).toBeInstanceOf(Commit);
});
it("Should get whole commit history", async() => {
expect.hasAssertions();
const history = await tree_entry.history();
expect(history).toBeDefined();
expect(history.length).toBeGreaterThanOrEqual(1);
for(const hist_entry of history) {
expect(hist_entry).toBeDefined();
expect(hist_entry).toBeInstanceOf(Commit);
}
});
it("Should get 5 entries of the commit history", async() => {
expect.hasAssertions();
const history = await tree_entry.history(5);
expect(history).toBeDefined();
expect(history).toHaveLength(5);
for(const hist_entry of history) {
expect(hist_entry).toBeDefined();
expect(hist_entry).toBeInstanceOf(Commit);
}
});
});
});
describe("Tree entry", () => {
describe("Class methods", () => {
let tree_entry: BaseTreeEntry;
beforeAll(async() => {
const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
const tree = await repository.tree();
const entry = tree.entries().find(entry => entry.path === "test");
if(!entry) {
throw(new Error("Couldn't find the test directory!"));
}
tree_entry = entry;
});
it("Should get the tree", async() => {
expect.assertions(2);
const entry = tree_entry as TreeEntry;
const tree = await entry.tree();
expect(tree).toBeDefined();
expect(tree).toBeInstanceOf(Tree);
});
});
});
describe("Blob tree entry", () => {
describe("Class methods", () => {
let tree_entry: BaseTreeEntry;
beforeAll(async() => {
const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
const tree = await repository.tree();
tree_entry = tree.entries()[0];
});
it("Should get the blob", async() => {
expect.assertions(2);
const entry = tree_entry as BlobTreeEntry;
const blob = await entry.blob();
expect(blob).toBeDefined();
expect(blob).toBeInstanceOf(Blob);
});
});
});
});
|