blob: 1fb164fa7b907390fdc076f3b9d90c953ccc332f (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import { Repository } from "server/src/git/repository";
import { Diff } from "server/src/git/diff";
import { EnvironmentVariables } from "../util";
import { Patch } from "server/src/git/patch";
const env = process.env as EnvironmentVariables;
describe("Diff", () => {
let diff: Diff;
beforeAll(async() => {
const repository = await Repository.open(env.BASE_DIR, env.AVAIL_REPO);
diff = await (await repository.masterCommit()).diff();
});
describe("Methods", () => {
it("Should get the raw patches", async() => {
expect.assertions(2);
const raw_patches = await diff.rawPatches();
expect(raw_patches).toBeDefined();
expect(typeof raw_patches).toEqual("string");
});
it("Should get the header data", async() => {
expect.assertions(4);
const patch_header_data = await diff.patchHeaderData();
expect(patch_header_data).toBeDefined();
expect(patch_header_data).toHaveProperty("indexes");
expect(patch_header_data).toHaveProperty("lengths");
expect(patch_header_data).toHaveProperty("last");
});
it("Should get the patches", async() => {
expect.hasAssertions();
const patches = await diff.patches();
expect(patches).toBeDefined();
for(const patch of patches) {
expect(patch).toBeDefined();
expect(patch).toBeInstanceOf(Patch);
}
});
});
});
|