Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing module generator and adding tests
- Loading branch information
1 parent
f3d5d23
commit 37a80c5
Showing
2 changed files
with
119 additions
and
44 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,77 @@ | ||
var assert = require('assert'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var exec = require('child_process').exec; | ||
var fs = require('fs-extra'); | ||
|
||
describe('generator-donejs', function() { | ||
describe('donejs:module', function() { | ||
it('basics works', function(done) { | ||
var tmpDir; | ||
|
||
helpers.run(path.join(__dirname, '../module')) | ||
.inTmpDir(function(dir) { | ||
var done = this.async(); | ||
tmpDir = dir; | ||
fs.copySync(path.join( __dirname, "tests", 'basics'), dir); | ||
done(); | ||
}) | ||
.withOptions({ | ||
skipInstall: true | ||
}) | ||
.withPrompts({ | ||
name: 'foo-bar' | ||
}) | ||
.on('end', function() { | ||
assert( fs.existsSync( path.join( tmpDir, "src", "foo-bar", "foo-bar.js" ) ), "foo-bar.js exists" ); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('allows to override template files', function (done) { | ||
var source = path.join(__dirname, 'tests', 'override', 'override.js'); | ||
var tmpDir, target; | ||
|
||
helpers.run(path.join(__dirname, '../module')) | ||
.inTmpDir(function (dir) { | ||
tmpDir = dir; | ||
target = path.join(dir, '.donejs', 'templates', 'module', 'module_test.js'); | ||
fs.copySync(path.join( __dirname, "tests", 'basics'), dir); | ||
fs.copySync(source, target); | ||
}) | ||
.withOptions({ | ||
skipInstall: true | ||
}) | ||
.withPrompts({ | ||
name: 'foo-bar' | ||
}) | ||
.on('end', function () { | ||
assert.fileContent(path.join( tmpDir, "src", "foo-bar", "foo-bar_test.js" ), | ||
/Overriden foo-bar test file/); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('throws an error if package.json is not present', function(done) { | ||
var tmpDir; | ||
|
||
helpers.run(path.join(__dirname, '../module')) | ||
.inTmpDir(function(dir) { | ||
var done = this.async(); | ||
tmpDir = dir; | ||
done(); | ||
}) | ||
.withOptions({ | ||
skipInstall: true | ||
}) | ||
.withPrompts({ | ||
name: 'foo-bar' | ||
}) | ||
.on('error', function(err){ | ||
var msg = err.message; | ||
assert(/No package.json/.test(msg), 'Error because of no package.json'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |