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
107 lines (76 loc) · 3.17 KB
/
gitgraph.js
File metadata and controls
107 lines (76 loc) · 3.17 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
describe( "Gitgraph.js", function () {
var gitGraph, master, develop, canvas;
beforeEach( function () {
document.body = document.createElement( "body" );
canvas = document.createElement( "canvas" );
} );
describe( "Gitgraph", function () {
it( "should hide messages in compact mode", function () {
gitGraph = new GitGraph( { canvas: canvas, mode: "compact" } );
expect( gitGraph.template.commit.message.display ).toEqual( false );
} );
it( "should load the right template", function () {
gitGraph = new GitGraph( { canvas: canvas, template: "blackarrow" } );
expect( gitGraph.template ).toEqual( gitGraph.newTemplate( "blackarrow" ) );
} );
it( "should load the default template", function () {
gitGraph = new GitGraph( { canvas: canvas, template: "wrongInput" } );
expect( gitGraph.template ).toEqual( gitGraph.newTemplate( "metro" ) );
} );
} );
describe( "Branch", function () {
beforeEach( function () {
gitGraph = new GitGraph( { canvas: canvas, template: "metro" } );
master = gitGraph.branch( "master" );
develop = gitGraph.branch( "develop" );
} );
it( "shoud have a name", function () {
expect( gitGraph.branches[ 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 () {
gitGraph = new GitGraph( { canvas: canvas, template: "blackarrow" } );
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 () {
master.commit().commit().commit();
expect( master.commits.length ).toEqual( 3 );
} );
} );
describe( "Commit", function () {
beforeEach( function () {
gitGraph = new GitGraph( { canvas: canvas, template: "metro" } );
master = gitGraph.branch( "master" );
master.commit().commit();
develop = gitGraph.branch( "develop" );
develop.commit();
master.commit( "message" );
gitGraph.commit( "plop" );
} );
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 );
} );
} );
} );