WIP have half of hg commands mapped

This commit is contained in:
Peter Cottle 2013-07-31 09:22:11 -07:00
parent 51e1cc2b77
commit a033173281
10 changed files with 817 additions and 27 deletions

55
spec/vcs.spec.js Normal file
View file

@ -0,0 +1,55 @@
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)
);
});
});
});