-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added additional tests for AbstractCommand.
- Loading branch information
Showing
4 changed files
with
48 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
const proxyquire = require('proxyquire'); | ||
const TestCommand = require('jasmine/test/mock/commands/TestCommand'); | ||
|
||
describe("jasmine.commands.AbstractCommand", function () { | ||
const AbstractCommand = proxyquire('jasmine/commands/AbstractCommand', {}); | ||
|
||
it('should not allow you to instantiate it directly', function () { | ||
assert.throws(function () { | ||
new AbstractCommand; | ||
}, TypeError); | ||
}); | ||
|
||
it('should allow extending classes to be instantiated', function () { | ||
let instance; | ||
let caller = {}; | ||
let switches = 'foo/bar/baz'; | ||
let args = 'foo bar baz'; | ||
assert.doesNotThrow(function () { | ||
instance = new TestCommand(caller, switches, args); | ||
}); | ||
|
||
assert.strictEqual(instance.caller, caller); | ||
assert.deepEqual(instance.switches, switches.split('/')); | ||
assert.deepEqual(instance.args, args.split(' ')); | ||
}); | ||
}); |
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,13 @@ | ||
'use strict'; | ||
|
||
const AbstractCommand = require('jasmine/commands/AbstractCommand'); | ||
|
||
class TestCommand extends AbstractCommand { | ||
static get command () { return 'test'; } | ||
static get aliases () { return ['foo']; } | ||
execute () { | ||
process.emit('executed TestCommand'); | ||
} | ||
} | ||
|
||
module.exports = TestCommand; |