mavensmate
Version:
Core APIs that drive MavensMate IDEs for Salesforce1/Force.com
60 lines (48 loc) • 1.66 kB
JavaScript
;
var assert = require('assert');
var sinon = require('sinon');
var sinonAsPromised = require('sinon-as-promised');
var util = require('../../../../app/lib/util');
var _ = require('lodash');
var helper = require('../../../test-helper');
var commandExecutor = require('../../../../app/lib/commands')();
sinonAsPromised(require('bluebird'));
describe('mavensmate new-lightning-component-cli', function(){
var program;
var commandExecutorStub;
var getPayloadStub;
before(function() {
program = helper.initCli();
});
beforeEach(function() {
commandExecutorStub = sinon.stub(program.commandExecutor, 'execute');
getPayloadStub = sinon.stub(util, 'getPayload').resolves({ foo : 'bar' });
});
afterEach(function() {
commandExecutorStub.restore();
getPayloadStub.restore();
});
it('should accept a ui flag', function(done) {
var cmd = _.find(program.commands, { _name : 'new-lightning-component' });
cmd.ui = true;
program._events['new-lightning-component']();
commandExecutorStub.calledOnce.should.equal(true);
assert(commandExecutorStub.calledWithMatch({
name: 'new-lightning-component',
body: { args: { ui: true } }
}));
cmd.ui = false;
done();
});
it('should accept stdin', function(done) {
program._events['new-lightning-component']();
getPayloadStub().then(function() {
commandExecutorStub.calledOnce.should.equal(true);
assert(commandExecutorStub.calledWithMatch({
name: 'new-lightning-component',
body: { foo : 'bar' }
}));
done();
});
});
});