forked from pcottle/learnGitBranching
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvcs.spec.js
More file actions
54 lines (47 loc) · 1.2 KB
/
vcs.spec.js
File metadata and controls
54 lines (47 loc) · 1.2 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
var Command = require('../src/js/models/commandModel').Command;
describe('commands', function() {
it('replaces . with HEAD correctly', function() {
var testCases = {
'.^': 'HEAD^',
'.': 'HEAD',
'.~4': 'HEAD~4'
};
var c = new Command({rawStr: 'foo'});
Object.keys(testCases).forEach(function(input) {
var expected = testCases[input];
var actual = c.replaceDotWithHead(input);
expect(actual).toBe(expected);
}.bind(this));
});
it('maps options and general args', function() {
var testCases = [{
args: ['.~4', 'HEAD^'],
options: {
'--amend': ['.'],
'-m': ['"oh hai"']
},
gitArgs: ['HEAD~4', 'HEAD^'],
gitOptions: {
'--amend': ['HEAD'],
'-m': ['"oh hai"']
}
}];
var c = new Command({rawStr: 'foo'});
testCases.forEach(function(tCase) {
c.setOptionsMap(tCase.options);
c.setGeneralArgs(tCase.args);
c.mapDotToHead();
var j = JSON.stringify;
expect(
j(c.getGeneralArgs())
).toBe(
j(tCase.gitArgs)
);
expect(
j(c.getOptionsMap())
).toBe(
j(tCase.gitOptions)
);
}.bind(this));
});
});