forked from brzpegasus/ember-cli-nwjs
-
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.
- Loading branch information
1 parent
8d2cf5b
commit 55e9f8b
Showing
14 changed files
with
443 additions
and
4 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,22 @@ | ||
language: node_js | ||
|
||
sudo: false | ||
|
||
node_js: | ||
- "0.10" | ||
- "0.12" | ||
- "iojs" | ||
|
||
cache: | ||
directories: | ||
- node_modules | ||
|
||
before_install: | ||
- npm config set spin false | ||
- npm install -g npm@^2 | ||
|
||
install: | ||
- npm install | ||
|
||
script: | ||
- npm 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
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,45 @@ | ||
{ | ||
"predef": [ | ||
"console", | ||
"it", | ||
"describe", | ||
"beforeEach", | ||
"afterEach", | ||
"before", | ||
"after", | ||
"-Promise" | ||
], | ||
"expr": true, | ||
"proto": true, | ||
"strict": true, | ||
"indent": 2, | ||
"camelcase": true, | ||
"node": true, | ||
"browser": false, | ||
"boss": true, | ||
"curly": true, | ||
"latedef": "nofunc", | ||
"debug": false, | ||
"devel": false, | ||
"eqeqeq": true, | ||
"evil": true, | ||
"forin": false, | ||
"immed": false, | ||
"laxbreak": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": false, | ||
"quotmark": true, | ||
"nonew": false, | ||
"nomen": false, | ||
"onevar": false, | ||
"plusplus": false, | ||
"regexp": false, | ||
"undef": true, | ||
"unused": true, | ||
"sub": true, | ||
"trailing": true, | ||
"white": false, | ||
"eqnull": true, | ||
"esnext": true | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
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,6 @@ | ||
var chai = require('chai'); | ||
var chaiAsPromised = require('chai-as-promised'); | ||
|
||
chai.use(chaiAsPromised); | ||
|
||
module.exports = chai.expect; |
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,3 @@ | ||
var mochaJSHint = require('mocha-jshint'); | ||
|
||
mochaJSHint(['lib']); |
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,22 @@ | ||
'use strict'; | ||
|
||
var glob = require('glob'); | ||
var Mocha = require('mocha'); | ||
|
||
var mocha = new Mocha({ | ||
reporter: 'spec' | ||
}); | ||
|
||
var root = 'tests/'; | ||
|
||
function addFiles(mocha, files) { | ||
glob.sync(root + files).forEach(mocha.addFile.bind(mocha)); | ||
} | ||
|
||
addFiles(mocha, '/**/*-test.js'); | ||
|
||
mocha.run(function(failures) { | ||
process.on('exit', function() { | ||
process.exit(failures); | ||
}); | ||
}); |
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,167 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var mockery = require('mockery'); | ||
var mockSpawn = require('mock-spawn'); | ||
var Command = require('ember-cli/lib/models/command'); | ||
var Task = require('ember-cli/lib/models/task'); | ||
var MockUI = require('ember-cli/tests/helpers/mock-ui'); | ||
var MockAnalytics = require('ember-cli/tests/helpers/mock-analytics'); | ||
var RSVP = require('rsvp'); | ||
var expect = require('../../helpers/expect'); | ||
|
||
describe("ember nw command", function() { | ||
var NWCommand, ui, analytics, project, spawn, _envNW; | ||
|
||
beforeEach(function() { | ||
spawn = mockSpawn(); | ||
mockery.enable({ useCleanCache: true }); | ||
mockery.registerMock('child_process', { spawn: spawn }); | ||
mockery.warnOnUnregistered(false); | ||
|
||
_envNW = process.env.NW_PATH; | ||
delete process.env.NW_PATH; | ||
|
||
var nwObject = require('../../../lib/commands/nw'); | ||
NWCommand = Command.extend(nwObject); | ||
|
||
ui = new MockUI(); | ||
analytics = new MockAnalytics(); | ||
|
||
project = { | ||
isEmberCLIProject: function() { | ||
return true; | ||
}, | ||
root: path.join(__dirname, '..', '..', 'fixtures', 'project-empty') | ||
}; | ||
}); | ||
|
||
afterEach(function() { | ||
process.env.NW_PATH = _envNW; | ||
|
||
mockery.deregisterAll(); | ||
mockery.resetCache(); | ||
mockery.disable(); | ||
}); | ||
|
||
it("should build the project before running nw.js", function() { | ||
var tasks = []; | ||
|
||
var command = new NWCommand({ | ||
ui: ui, | ||
analytics: analytics, | ||
project: project, | ||
settings: {}, | ||
buildWatch: function() { | ||
tasks.push('buildWatch'); | ||
return RSVP.resolve(); | ||
}, | ||
runNW: function() { | ||
tasks.push('runNW'); | ||
return RSVP.resolve(); | ||
} | ||
}).validateAndRun(); | ||
|
||
return expect(command).to.be.fulfilled | ||
.then(function() { | ||
expect(tasks).to.deep.equal(['buildWatch', 'runNW']); | ||
}); | ||
}); | ||
|
||
it("should not run nw.js when the build fails", function() { | ||
var tasks = []; | ||
|
||
var command = new NWCommand({ | ||
ui: ui, | ||
analytics: analytics, | ||
project: project, | ||
settings: {}, | ||
buildWatch: function() { | ||
tasks.push('buildWatch'); | ||
return RSVP.reject(); | ||
}, | ||
runNW: function() { | ||
tasks.push('runNW'); | ||
return RSVP.resolve(); | ||
} | ||
}).validateAndRun(); | ||
|
||
return expect(command).to.be.rejected | ||
.then(function() { | ||
expect(tasks).to.deep.equal(['buildWatch']); | ||
}); | ||
}); | ||
|
||
it("should not keep watching if nw.js fails to run", function() { | ||
var tasks = []; | ||
|
||
var command = new NWCommand({ | ||
ui: ui, | ||
analytics: analytics, | ||
project: project, | ||
settings: {}, | ||
buildWatch: function() { | ||
tasks.push('buildWatch'); | ||
return RSVP.resolve(); | ||
}, | ||
runNW: function() { | ||
tasks.push('runNW'); | ||
return RSVP.reject(); | ||
} | ||
}).validateAndRun(); | ||
|
||
return expect(command).to.be.rejected | ||
.then(function() { | ||
expect(tasks).to.deep.equal(['buildWatch', 'runNW']); | ||
}); | ||
}); | ||
|
||
it("should spawn a 'nw' process with the right arguments", function() { | ||
var command = new NWCommand({ | ||
ui: ui, | ||
analytics: analytics, | ||
project: project, | ||
settings: {}, | ||
buildWatch: function() { | ||
return RSVP.resolve(); | ||
} | ||
}).validateAndRun(); | ||
|
||
return expect(command).to.be.fulfilled | ||
.then(function() { | ||
expect(spawn.calls.length).to.equal(1); | ||
expect(spawn.calls[0].command).to.equal('nw'); | ||
expect(spawn.calls[0].args).to.deep.equal(['.']); | ||
|
||
expect(ui.output).to.contain("Starting nw.js..."); | ||
expect(ui.output).to.contain("nw.js exited."); | ||
}); | ||
}); | ||
|
||
it("should print a friendly message when the 'nw' command cannot be found", function() { | ||
var command = new NWCommand({ | ||
ui: ui, | ||
analytics: analytics, | ||
project: project, | ||
settings: {}, | ||
buildWatch: function() { | ||
return RSVP.resolve(); | ||
} | ||
}).validateAndRun(); | ||
|
||
spawn.sequence.add(function() { | ||
this.emit('error', { code: 'ENOENT' }); | ||
}); | ||
|
||
return expect(command).to.be.rejected | ||
.then(function() { | ||
expect(spawn.calls.length).to.equal(1); | ||
expect(spawn.calls[0].command).to.equal('nw'); | ||
expect(spawn.calls[0].args).to.deep.equal(['.']); | ||
|
||
expect(ui.output).to.contain("Starting nw.js..."); | ||
expect(ui.output).to.contain("Error running the following command: nw"); | ||
expect(ui.output).to.contain("re-run the blueprint"); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.