-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Increasing coverage - donejs-cli package.json was required from wrong path - cli was throwing silently if folder had no package.json while looking up for local npm scripts
- Loading branch information
Manuel Mujica
committed
Apr 6, 2016
1 parent
f6189bd
commit 5648441
Showing
9 changed files
with
155 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
require('./tests/cli-test'); | ||
require('./tests/utils-test'); | ||
require('./tests/cmd-init-test'); | ||
require('./tests/cmd-add-test'); | ||
require('./tests/cmd-init-test'); | ||
require('./tests/cmd-generate-test'); | ||
require('./tests/get-local-bins-test'); | ||
require('./tests/get-npm-scripts-test'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
var path = require('path'); | ||
var assert = require('assert'); | ||
var concat = require('concat-stream'); | ||
var spawn = require('cross-spawn-async'); | ||
var pkg = require('../../package.json'); | ||
var cli = require('../../lib/cli/index'); | ||
|
||
describe('./bin/donejs', function() { | ||
var command; | ||
var program; | ||
|
||
beforeEach(function() { | ||
command = path.join(__dirname, '..', '..', 'bin', 'donejs'); | ||
program = cli(__dirname); | ||
}); | ||
|
||
it.skip('shows cli help when no options passed', function(done) { | ||
var proc = spawn(command, []); | ||
it('reports the correct package version', function() { | ||
assert.equal(program.version(), pkg.version); | ||
}); | ||
|
||
it('includes the init, add and generate commands', function() { | ||
var cliCommands = program.commands.map(function(cmd) { | ||
return cmd._name; | ||
}); | ||
|
||
assert(has(cliCommands, 'init'), 'should include init'); | ||
assert(has(cliCommands, 'add'), 'should include add'); | ||
assert(has(cliCommands, 'generate'), 'should include generate'); | ||
}); | ||
|
||
it('includes local scripts and binaries as commands', function() { | ||
program = cli(path.join(__dirname, '..', '..')); | ||
|
||
proc.stdout.pipe(concat(function(output) { | ||
var res = output.toString('utf8'); | ||
var cliCommands = program.commands.map(function(cmd) { | ||
return cmd._name; | ||
}); | ||
|
||
assert(/Usage: donejs \[options\]/.test(res), 'should show cli help'); | ||
done(); | ||
})); | ||
assert(has(cliCommands, 'test'), 'should include test'); | ||
assert(has(cliCommands, 'jshint'), 'should include jshint'); | ||
assert(has(cliCommands, 'coverage'), 'should include coverage'); | ||
assert(has(cliCommands, 'mocha'), 'should include mocha'); | ||
assert(has(cliCommands, 'documentjs'), 'should include documentjs'); | ||
}); | ||
|
||
function has(coll, cmd) { | ||
return coll.indexOf(cmd) !== -1; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var Q = require('q'); | ||
var path = require('path'); | ||
var assert = require('assert'); | ||
var mockery = require('mockery'); | ||
|
||
describe('cli generate cmd', function() { | ||
it('calls generate with the right arguments', function() { | ||
var params = {}; | ||
var name = 'component'; | ||
var generateCalled = false; | ||
var root = path.join(__dirname, '..', '..'); | ||
var cmdGeneratePath = '../../lib/cli/cmd-generate'; | ||
|
||
mockery.registerAllowable(cmdGeneratePath); | ||
|
||
mockery.registerMock('../utils', { | ||
generate: function() { | ||
var args = Array.prototype.slice.call(arguments); | ||
|
||
assert.equal(args[0], path.join(root, 'node_modules')); | ||
assert.equal(args[1], 'generator-donejs'); | ||
assert.deepEqual(args[2], [ ['component', {}] ]); | ||
generateCalled = true; | ||
|
||
return Q(true); | ||
} | ||
}); | ||
|
||
mockery.enable({ | ||
useCleanCache: true, | ||
warnOnUnregistered: false | ||
}); | ||
|
||
var generate = require(cmdGeneratePath); | ||
|
||
return generate(root, name, params) | ||
.then(function() { | ||
assert(generateCalled, 'generate should be called'); | ||
mockery.disable(); | ||
mockery.deregisterAll(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters