-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for Exam command and minor refactor
- Loading branch information
Trent Willis
committed
Dec 4, 2015
1 parent
c1ad5e8
commit e469d3d
Showing
2 changed files
with
118 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
var assert = require('assert'); | ||
var RSVP = require('rsvp'); | ||
var MockProject = require('ember-cli/tests/helpers/mock-project'); | ||
var Task = require('ember-cli/lib/models/task'); | ||
|
||
var ExamCommand = require('../../../lib/commands/exam'); | ||
var TestsProcessor = require('../../../lib/utils/tests-processor'); | ||
|
||
describe('ExamCommand', function() { | ||
describe('run', function() { | ||
var command; | ||
var superCall; | ||
var originalBuildRun; | ||
|
||
beforeEach(function() { | ||
var tasks = { | ||
Build: Task.extend() | ||
}; | ||
|
||
originalBuildRun = tasks.Build.prototype.run = function() { | ||
return RSVP.Promise.resolve(); | ||
}; | ||
|
||
var project = new MockProject(); | ||
|
||
project.isEmberCLIProject = function() { return true; }; | ||
|
||
command = new ExamCommand({ | ||
project: project, | ||
tasks: tasks | ||
}); | ||
|
||
superCall = { called: false }; | ||
command._super.run = function(options) { | ||
superCall = { | ||
called: true, | ||
options: options | ||
} | ||
}; | ||
}); | ||
|
||
it('should defer to super with normal build task', function() { | ||
command.run({}); | ||
|
||
assert.equal(originalBuildRun, command.tasks.Build.prototype.run); | ||
assert.equal(superCall.called, true); | ||
}); | ||
|
||
it('should defer to super after patching the build task', function() { | ||
command.run({ split: 2 }); | ||
|
||
assert.notEqual(originalBuildRun, command.tasks.Build.prototype.run); | ||
assert.equal(superCall.called, true); | ||
}); | ||
|
||
it('should run a test processor after the build runs', function(done) { | ||
var processorCalled = false; | ||
|
||
command.utils.Processor = function ProcessorStub() { | ||
processorCalled = true; | ||
this.write = function() { | ||
return RSVP.Promise.resolve(); | ||
}; | ||
}; | ||
|
||
command.run({ split: 2 }); | ||
|
||
var build = new command.tasks.Build(); | ||
build.run({ outputPath: 'dist' }).then(function() { | ||
assert.equal(processorCalled, true); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should set \'splitFile\' to the query option', function() { | ||
command.run({ split: 2, splitFile: 2 }); | ||
|
||
assert.equal(superCall.options.query, 'splitFile=2'); | ||
assert.equal(superCall.called, true); | ||
}); | ||
|
||
it('should append \'splitFile\' to the query option', function() { | ||
command.run({ split: 2, splitFile: 2, query: 'someQuery=derp&hidepassed' }); | ||
|
||
assert.equal(superCall.options.query, 'someQuery=derp&hidepassed&splitFile=2'); | ||
assert.equal(superCall.called, true); | ||
}); | ||
}); | ||
}); |