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
|
import { Repository } from "server/src/git/repository";
describe("Repository", () => {
test("Open existing repository", async () => {
const openRepository = jest.fn(() => Repository.open(process.env.BASE_DIR, process.env.AVAIL_REPO));
await openRepository();
expect(openRepository).toReturn();
});
test("Open nonexistant repository throws", async () => {
expect(Repository.open(process.env.BASE_DIR, process.env.UNAVAIL_REPO)).rejects.toThrow();
});
test("Open all repositories", async () => {
const openAllRepositories = jest.fn(() => Repository.openAll(process.env.BASE_DIR));
await openAllRepositories();
expect(openAllRepositories).toReturn();
});
describe("Functions", () => {
let repository: Repository;
beforeAll(async () => {
repository = await Repository.open(process.env.BASE_DIR, process.env.AVAIL_REPO);
});
test("Lookup if an existing object exists", async () => {
const exists = await repository.lookupExists(process.env.AVAIL_OBJECT);
expect(exists).toBeTruthy();
});
test("Lookup if an nonexistant object exists", async () => {
const exists = await repository.lookupExists(process.env.UNAVAIL_OBJECT);
expect(exists).toBeFalsy();
});
test("Get latest commit", async () => {
const getLatestCommit = jest.fn(() => repository.latestCommit());
await getLatestCommit();
expect(getLatestCommit).toReturn();
});
test("Get commits", async () => {
const getCommits = jest.fn(() => repository.commits());
await getCommits();
expect(getCommits).toReturn();
});
test("Get tree", async () => {
const getTree = jest.fn(() => repository.tree());
await getTree();
expect(getTree).toReturn();
});
test("Get branches", async () => {
const getBranches = jest.fn(() => repository.branches());
await getBranches();
expect(getBranches).toReturn();
});
test("Get tags", async () => {
const getTags = jest.fn(() => repository.tags());
await getTags();
expect(getTags).toReturn();
});
});
});
|