Skip to content

Commit

Permalink
converting asserts to sinon.assert stmts
Browse files Browse the repository at this point in the history
  • Loading branch information
grawk committed Oct 27, 2014
1 parent 9a8838c commit 6ee6b84
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/install.js
Expand Up @@ -2,7 +2,6 @@
'use strict';
var yeoman = require('yeoman-environment');
var generators = require('..');
var assert = generators.assert;
var helpers = generators.test;
var TestAdapter = require('../lib/test/adapter').TestAdapter;
var sinon = require('sinon');
Expand Down Expand Up @@ -36,44 +35,44 @@ describe('generators.Base (actions/install mixin)', function () {
};
//args: installer, paths, options, cb
this.dummy.runInstall('nestedScript', ['path1', 'path2'], spawnEnv, done);
assert.ok(this.spawnCommandStub.calledWithExactly('nestedScript', ['install', 'path1', 'path2'], spawnEnv));
sinon.assert.calledWithExactly(this.spawnCommandStub, 'nestedScript', ['install', 'path1', 'path2'], spawnEnv);
});
});

describe('#bowerInstall()', function () {
it('spawn a bower process', function (done) {
this.dummy.bowerInstall(null, done);
assert.ok(this.spawnCommandStub.calledOnce);
assert.ok(this.spawnCommandStub.calledWithExactly('bower', ['install'], {}));
sinon.assert.calledOnce(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'bower', ['install'], {});
});

it('spawn a bower process with formatted options', function (done) {
this.dummy.bowerInstall('jquery', { saveDev: true }, done);
assert.ok(this.spawnCommandStub.calledOnce);
assert.ok(this.spawnCommandStub.calledWithExactly('bower', ['install', 'jquery', '--save-dev'], { saveDev: true }));
sinon.assert.calledOnce(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'bower', ['install', 'jquery', '--save-dev'], { saveDev: true });
});
});

describe('#npmInstall()', function () {
it('run without callback', function () {
this.dummy.npmInstall('yo', { save: true });
assert.ok(this.spawnCommandStub.calledOnce);
sinon.assert.calledOnce(this.spawnCommandStub);
});
});

describe('#installDependencies()', function () {
it('spawn npm and bower', function (done) {
this.dummy.installDependencies(function () {
assert.ok(this.spawnCommandStub.firstCall.calledWithExactly('bower', ['install'], {}));
assert.ok(this.spawnCommandStub.secondCall.calledWithExactly('npm', ['install'], {}));

sinon.assert.calledTwice(this.spawnCommandStub);
sinon.assert.calledWithExactly(this.spawnCommandStub, 'bower', ['install'], {});
sinon.assert.calledWithExactly(this.spawnCommandStub, 'npm', ['install'], {});
done();
}.bind(this));
});

it('doesn\'t spawn anything with skipInstall', function () {
this.dummy.installDependencies({ skipInstall: true });
assert.equal(this.spawnCommandStub.callCount, 0);
sinon.assert.notCalled(this.spawnCommandStub);
});

it('call callback if skipInstall', function (done) {
Expand Down

0 comments on commit 6ee6b84

Please sign in to comment.