mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 00:18:56 +02:00
55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
var _ = require('underscore');
|
|
|
|
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'});
|
|
_.each(testCases, function(expected, input) {
|
|
var actual = c.replaceDotWithHead(input);
|
|
expect(actual).toBe(expected);
|
|
});
|
|
});
|
|
|
|
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'});
|
|
_.each(testCases, function(tCase) {
|
|
c.setSupportedMap(tCase.options);
|
|
c.setGeneralArgs(tCase.args);
|
|
c.mapDotToHead();
|
|
|
|
var j = JSON.stringify;
|
|
expect(
|
|
j(c.getGeneralArgs())
|
|
).toBe(
|
|
j(tCase.gitArgs)
|
|
);
|
|
|
|
expect(
|
|
j(c.getSupportedMap())
|
|
).toBe(
|
|
j(tCase.gitOptions)
|
|
);
|
|
});
|
|
});
|
|
});
|
|
|