-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial test migration to buster. Update command handling with latest…
… bagofholding. Upgrade deps.
- Loading branch information
Showing
8 changed files
with
157 additions
and
131 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"commands": { | ||
"init": { | ||
"desc": "Create example AE86 project files\nUsage: ae86 init" | ||
}, | ||
"gen": { | ||
"desc": "Generate website\nUsage: ae86 gen" | ||
}, | ||
"watch": { | ||
"desc": "Watch for changes and automatically regenerate website\nUsage: ae86 watch" | ||
}, | ||
"drift": { | ||
"desc": "Alias for watch\nUsage: ae86 drift" | ||
}, | ||
"clean": { | ||
"desc": "Remove website\nUsage: ae86 clean" | ||
} | ||
} | ||
} |
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,52 +1,38 @@ | ||
var _ = require('underscore'), | ||
ae86 = require('./ae86'), | ||
var ae86 = require('./ae86'), | ||
bag = require('bagofholding'); | ||
|
||
function _init() { | ||
new ae86().init(bag.cli.exit); | ||
} | ||
|
||
function _gen() { | ||
new ae86().generate(bag.cli.exit); | ||
} | ||
|
||
function _watch() { | ||
new ae86().watch(bag.cli.exit); | ||
} | ||
|
||
function _clean() { | ||
new ae86().clean(bag.cli.exit); | ||
} | ||
|
||
/** | ||
* Execute AE86 using template files in the current directory. | ||
* Execute AE86 CLI. | ||
*/ | ||
function exec() { | ||
|
||
function _init() { | ||
new ae86().init(bag.cli.exit); | ||
} | ||
|
||
function _generate() { | ||
new ae86().generate(bag.cli.exit); | ||
} | ||
|
||
function _watch() { | ||
new ae86().watch(bag.cli.exit); | ||
} | ||
|
||
function _clean() { | ||
new ae86().clean(bag.cli.exit); | ||
} | ||
|
||
var commands = { | ||
init: { | ||
desc: 'Create example AE86 project files', | ||
action: _init | ||
}, | ||
gen: { | ||
desc: 'Generate website', | ||
action: _generate | ||
}, | ||
watch: { | ||
desc: 'Watch for changes and automatically regenerate website', | ||
action: _watch | ||
}, | ||
drift: { | ||
desc: 'Alias for watch', | ||
action: _watch | ||
}, | ||
clean: { | ||
desc: 'Remove website', | ||
action: _clean | ||
var actions = { | ||
commands: { | ||
init: { action: _init }, | ||
gen: { action: _gen }, | ||
watch: { action: _watch }, | ||
drift: { action: _watch }, | ||
clean: { action: _clean } | ||
} | ||
}; | ||
|
||
bag.cli.parse(commands, __dirname); | ||
bag.cli.command(__dirname, actions); | ||
} | ||
|
||
exports.exec = exec; |
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,83 +1,100 @@ | ||
var bag = require('bagofholding'), | ||
sandbox = require('sandboxed-module'), | ||
should = require('should'), | ||
checks, mocks, | ||
cli; | ||
buster = require('buster'), | ||
cli = require('../lib/cli'), | ||
AE86 = new require('../lib/ae86'); | ||
|
||
describe('cli', function () { | ||
buster.testCase('cli - exec', { | ||
'should contain commands with actions': function (done) { | ||
var mockCommand = function (base, actions) { | ||
assert.defined(base); | ||
assert.defined(actions.commands.init.action); | ||
assert.defined(actions.commands.gen.action); | ||
assert.defined(actions.commands.watch.action); | ||
assert.defined(actions.commands.drift.action); | ||
assert.defined(actions.commands.clean.action); | ||
done(); | ||
}; | ||
this.stub(bag, 'cli', { command: mockCommand }); | ||
cli.exec(); | ||
} | ||
}); | ||
|
||
function create(checks, mocks) { | ||
return sandbox.require('../lib/cli', { | ||
requires: { | ||
bagofholding: { | ||
cli: { | ||
exit: bag.cli.exit, | ||
parse: function (commands, dir) { | ||
checks.bag_parse_commands = commands; | ||
checks.bag_parse_dir = dir; | ||
} | ||
} | ||
}, | ||
'./ae86': function () { | ||
return { | ||
init: function (exit) { | ||
checks.ae86_init_exit = exit; | ||
}, | ||
generate: function (exit) { | ||
checks.ae86_gen_exit = exit; | ||
}, | ||
watch: function (exit) { | ||
checks.ae86_watch_exit = exit; | ||
}, | ||
clean: function (exit) { | ||
checks.ae86_clean_exit = exit; | ||
} | ||
}; | ||
} | ||
buster.testCase('cli - init', { | ||
'should contain init command and delegate to ae86 init when exec is called': function (done) { | ||
this.stub(bag, 'cli', { | ||
command: function (base, actions) { | ||
actions.commands.init.action(); | ||
}, | ||
globals: { | ||
process: bag.mock.process(checks, mocks) | ||
} | ||
exit: bag.cli.exit | ||
}); | ||
this.stub(AE86.prototype, 'init', function (cb) { | ||
assert.equals(typeof bag.cli.exit, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
} | ||
}); | ||
|
||
beforeEach(function () { | ||
checks = {}; | ||
mocks = {}; | ||
cli = create(checks, mocks); | ||
buster.testCase('cli - gen', { | ||
'should contain gen command and delegate to ae86 generate when exec is called': function (done) { | ||
this.stub(bag, 'cli', { | ||
command: function (base, actions) { | ||
actions.commands.gen.action(); | ||
}, | ||
exit: bag.cli.exit | ||
}); | ||
this.stub(AE86.prototype, 'generate', function (cb) { | ||
assert.equals(typeof bag.cli.exit, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
}); | ||
|
||
describe('exec', function () { | ||
} | ||
}); | ||
|
||
it('should contain init command and delegate to ae86 init when exec is called', function () { | ||
checks.bag_parse_commands.init.desc.should.equal('Create example AE86 project files'); | ||
checks.bag_parse_commands.init.action(); | ||
checks.ae86_init_exit.should.be.a('function'); | ||
buster.testCase('cli - watch', { | ||
'should contain watch command and delegate to ae86 watch when exec is called': function (done) { | ||
this.stub(bag, 'cli', { | ||
command: function (base, actions) { | ||
actions.commands.watch.action(); | ||
}, | ||
exit: bag.cli.exit | ||
}); | ||
|
||
it('should contain gen command and delegate to ae86 gen when exec is called', function () { | ||
checks.bag_parse_commands.gen.desc.should.equal('Generate website'); | ||
checks.bag_parse_commands.gen.action(); | ||
checks.ae86_gen_exit.should.be.a('function'); | ||
this.stub(AE86.prototype, 'watch', function (cb) { | ||
assert.equals(typeof bag.cli.exit, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
} | ||
}); | ||
|
||
it('should contain watch command and delegate to ae86 watch when exec is called', function () { | ||
checks.bag_parse_commands.watch.desc.should.equal('Watch for changes and automatically regenerate website'); | ||
checks.bag_parse_commands.watch.action(); | ||
checks.ae86_watch_exit.should.be.a('function'); | ||
buster.testCase('cli - drift', { | ||
'should contain drift command and delegate to ae86 watch when exec is called': function (done) { | ||
this.stub(bag, 'cli', { | ||
command: function (base, actions) { | ||
actions.commands.watch.action(); | ||
}, | ||
exit: bag.cli.exit | ||
}); | ||
|
||
it('should contain drift command and delegate to ae86 watch when exec is called', function () { | ||
checks.bag_parse_commands.drift.desc.should.equal('Alias for watch'); | ||
checks.bag_parse_commands.drift.action(); | ||
checks.ae86_watch_exit.should.be.a('function'); | ||
this.stub(AE86.prototype, 'watch', function (cb) { | ||
assert.equals(typeof bag.cli.exit, 'function'); | ||
done(); | ||
}); | ||
cli.exec(); | ||
} | ||
}); | ||
|
||
it('should contain clean command and delegate to ae86 clean when exec is called', function () { | ||
checks.bag_parse_commands.clean.desc.should.equal('Remove website'); | ||
checks.bag_parse_commands.clean.action(); | ||
checks.ae86_clean_exit.should.be.a('function'); | ||
buster.testCase('cli - clean', { | ||
'should contain clean command and delegate to ae86 clean when exec is called': function (done) { | ||
this.stub(bag, 'cli', { | ||
command: function (base, actions) { | ||
actions.commands.clean.action(); | ||
}, | ||
exit: bag.cli.exit | ||
}); | ||
this.stub(AE86.prototype, 'clean', function (cb) { | ||
assert.equals(typeof bag.cli.exit, 'function'); | ||
done(); | ||
}); | ||
}); | ||
cli.exec(); | ||
} | ||
}); |
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