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
|
import { Branch } from "../../packages/server/src/git/branch";
import { Repository } from "../../packages/server/src/git/repository";
import { EnvironmentVariables } from "../util";
const env = process.env as EnvironmentVariables;
describe("Branch", () => {
describe("Class methods", () => {
it("Should lookup a branch", async() => {
expect.assertions(2);
const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO);
const branch = await Branch.lookup(repository, "master");
expect(branch).toBeDefined();
expect(branch).toBeInstanceOf(Branch);
});
it("Should lookup if an existent branch exists and respond true", async() => {
expect.assertions(2);
const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO);
const branch_exists = await Branch.lookupExists(repository.ng_repository, "master");
expect(branch_exists).toBeDefined();
expect(branch_exists).toBeTruthy();
});
it("Should lookup if an nonexistent branch exists and respond false", async() => {
expect.assertions(2);
const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO);
const branch_exists = await Branch.lookupExists(repository.ng_repository, "wubbalubbadubdub");
expect(branch_exists).toBeDefined();
expect(branch_exists).toBeFalsy();
});
});
describe("Instance methods", () => {
let branch: Branch;
beforeAll(async() => {
const repository = await Repository.open(env.GIT_DIR, env.AVAIL_REPO);
branch = await Branch.lookup(repository, "master");
});
it("Should get the latest commit", async() => {
expect.assertions(4);
const latest_commit = await branch.latestCommit();
expect(latest_commit).toBeDefined();
expect(latest_commit).toHaveProperty("id");
expect(latest_commit).toHaveProperty("message");
expect(latest_commit).toHaveProperty("date");
});
});
});
|