forked from nicoespeon/gitgraph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitgraph.js
More file actions
112 lines (94 loc) · 2.97 KB
/
gitgraph.js
File metadata and controls
112 lines (94 loc) · 2.97 KB
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
112
// Unit tests for the `GitGraph` library.
describe("Gitgraph", function () {
// Scenario - basic variables for tests
// TO BE REFACTOR for proper testing (beforeEach / afterEach)
var body = document.createElement("body");
document.body = body;
var gitGraph = new GitGraph({
canvas: document.createElement("canvas"),
template: "metro"
});
var master = gitGraph.branch("master").commit().commit();
var develop = gitGraph.branch("develop").commit();
master.commit("message");
gitGraph.commit("plop");
it("should hide messages in compact mode", function () {
var gitGraph = new GitGraph({
canvas: document.createElement("canvas"),
mode: "compact"
});
expect(gitGraph.template.commit.message.display)
.toEqual(false);
});
it("should load the right template", function () {
expect(gitGraph.template)
.toEqual(gitGraph.newTemplate("metro"));
});
it("should load the default template", function () {
var gitGraph = new GitGraph({
canvas: document.createElement("canvas"),
template: "wrongInput"
});
expect(gitGraph.template)
.toEqual(gitGraph.newTemplate("metro"));
});
describe("Branch", function () {
it("shoud have a name", function () {
expect(gitGraph.branchs[0].name)
.toEqual("master");
});
it("should be HEAD on develop", function () {
expect(gitGraph.HEAD)
.toEqual(develop);
});
it("should have the first color of template theme", function () {
expect(master.color)
.toEqual(gitGraph.template.colors[0]);
});
it("should have the color of branch template", function () {
var gitGraph = new GitGraph({
canvas: document.createElement("canvas"),
template: "blackarrow"
});
var master = gitGraph.branch("master");
expect(master.color)
.toEqual(gitGraph.template.branch.color);
});
it("should have the right column number", function () {
expect(master.column)
.toEqual(0);
expect(develop.column)
.toEqual(1);
});
it("should have the right commits count", function () {
expect(master.commits.length)
.toEqual(3);
expect(develop.commits.length)
.toEqual(2);
});
});
describe("Commit", function () {
it("should have the right message", function () {
expect(master.commits[2].message)
.toEqual("message");
});
it("should have a pretty color", function () {
expect(master.commits[2].dotColor)
.toEqual(gitGraph.template.colors[0]);
expect(master.commits[2].messageColor)
.toEqual(gitGraph.template.colors[0]);
});
it("should have the right position", function () {
// Commit on master
expect(master.commits[2].x)
.toEqual(0);
expect(master.commits[2].y)
.toEqual(240);
// Commit on develop
expect(develop.commits[1].x)
.toEqual(50);
expect(develop.commits[1].y)
.toEqual(320);
});
});
});