Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanforbes committed Oct 18, 2013
1 parent b5cc45a commit 4c0177d
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- '0.10'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"url": "git://github.com/bryanforbes/generator-dojo.git"
},
"scripts": {
"test": "mocha"
"test": "node node_modules/intern/client.js config=test/intern.js"
},
"dependencies": {
"yeoman-generator": "~0.13.0"
},
"devDependencies": {
"mocha": "~1.12.0"
"intern": "~1.2.1"
},
"peerDependencies": {
"yo": ">=1.0.0-rc.1"
Expand Down
57 changes: 57 additions & 0 deletions test/creation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* jshint node:true */
define([
'intern!object',
'intern/chai!assert',
'intern/node_modules/dojo/Deferred',
'intern/node_modules/dojo/node!path',
'intern/node_modules/dojo/node!yeoman-generator',
'module'
], function (registerSuite, assert, Deferred, path, generator, module) {
var helpers = generator.test,
app;

registerSuite({
name: 'creation',

beforeEach: function () {
var dfd = new Deferred();

helpers.testDirectory(path.join(path.dirname(module.uri), 'temp'), function (err) {
if (err) {
return dfd.reject(err);
}

app = helpers.createGenerator('dojo:app', [
'../../app'
]);

dfd.resolve();
});

return dfd.promise;
},

'expected files': function () {
var dfd = this.async(),
expected = [
'.jshintrc',
'.editorconfig',
'src/temp/resources/main.styl'
];

helpers.mockPrompt(app, {
'dojoVersion': '1.9.1',
'features': [ 'dijit', 'dgrid', 'stylus' ],
'dgridVersion': '0.3.10',
'nib': true,
'compression': 'closure',
'travisci': false
});
app.options['skip-install'] = true;
app.run({}, function () {
helpers.assertFiles(expected);
dfd.resolve();
});
}
});
});
20 changes: 20 additions & 0 deletions test/intern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Learn more about configuring this file at <https://github.com/theintern/intern/wiki/Configuring-Intern>.
// These default settings work OK for most people. The options that *must* be changed below are the
// packages, suites, excludeInstrumentation, and (if you want functional tests) functionalSuites.
define({
// Configuration options for the module loader; any AMD configuration options supported by the Dojo loader can be
// used here
loader: {
// Packages that should be registered with the loader in each testing environment
packages: [ { name: 'generator-dojo', location: '.' } ]
},

// Non-functional test suite(s) to run in each browser
suites: [ 'generator-dojo/test/load', 'generator-dojo/test/creation' ],

// Functional test suite(s) to run in each browser once non-functional tests are completed
functionalSuites: [ /* 'myPackage/tests/functional' */ ],

// A regular expression matching URLs to files that should not be included in code coverage analysis
excludeInstrumentation: /^tests\//
});
13 changes: 13 additions & 0 deletions test/load.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
define([
'intern!object',
'intern/chai!assert',
'intern/node_modules/dojo/node!../../../../../app'
], function (registerSuite, assert, app) {
registerSuite({
name: 'load',

'import': function () {
assert(app !== undefined);
}
});
});

0 comments on commit 4c0177d

Please sign in to comment.