Permalink
Browse files

chore(tests): update test helpers

  • Loading branch information...
1 parent 22a638e commit 980d8f0b614341113f7467f333729a00f094a7a5 @SBoudrias SBoudrias committed with eddiemonge Dec 29, 2015
Showing with 31 additions and 24 deletions.
  1. +3 −1 package.json
  2. +7 −5 test/test-appname-substitution.js
  3. +7 −6 test/test-apppath.js
  4. +8 −7 test/test-file-creation.js
  5. +1 −1 test/test-load.js
  6. +5 −4 test/test-route-creation.js
View
@@ -52,7 +52,9 @@
"grunt-conventional-github-releaser": "^0.5.0",
"load-grunt-tasks": "^3.1.0",
"mocha": "*",
- "underscore.string": "^3.0.3"
+ "underscore.string": "^3.0.3",
+ "yeoman-assert": "^2.1.1",
+ "yeoman-test": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
@@ -2,6 +2,8 @@
var path = require('path');
var helpers = require('yeoman-generator').test;
+var assert = require('yeoman-assert');
+
describe('Angular generator template', function () {
var angular;
@@ -40,27 +42,27 @@ describe('Angular generator template', function () {
it('should generate the same appName in every file', function (done) {
angular.run({}, function () {
- helpers.assertFile([
+ assert.file([
'app/scripts/app.js',
'app/scripts/controllers/main.js',
'app/index.html',
'test/spec/controllers/main.js'
]);
- helpers.assertFileContent(
+ assert.fileContent(
'app/scripts/app.js',
new RegExp('module\\(\'' + appName + 'App\'')
);
- helpers.assertFileContent(
+ assert.fileContent(
'app/scripts/controllers/main.js',
new RegExp('module\\(\'' + appName + 'App\'')
);
- helpers.assertFileContent(
+ assert.fileContent(
'test/spec/controllers/main.js',
new RegExp('module\\(\'' + appName + 'App\'')
);
- helpers.assertFileContent(
+ assert.fileContent(
'app/index.html',
new RegExp('ng-app=\"' + appName + 'App\"')
);
View
@@ -2,6 +2,7 @@
var path = require('path');
var helpers = require('yeoman-generator').test;
+var assert = require('yeoman-assert');
var _ = require('underscore.string');
describe('Angular generator appPath option', function () {
@@ -62,14 +63,14 @@ describe('Angular generator appPath option', function () {
describe('App files', function () {
it('should generate dotfiles for apppath', function (done) {
angular.run({}, function () {
- helpers.assertFile(expected);
+ assert.file(expected);
done();
});
});
it('creates expected JS files', function (done) {
angular.run({}, function() {
- helpers.assertFile([].concat(expected, [
+ assert.file([].concat(expected, [
'.jscsrc',
appPath + '/scripts/app.js',
appPath + '/scripts/controllers/main.js',
@@ -82,7 +83,7 @@ describe('Angular generator appPath option', function () {
it('creates CoffeeScript files', function (done) {
angular.env.options.coffee = true;
angular.run([], function () {
- helpers.assertFile([].concat(expected, [
+ assert.file([].concat(expected, [
appPath + '/scripts/app.coffee',
appPath + '/scripts/controllers/main.coffee',
'test/spec/controllers/main.coffee'
@@ -101,7 +102,7 @@ describe('Angular generator appPath option', function () {
angular.run([], function () {
angularGenerator.run([], function () {
- helpers.assertFileContent([
+ assert.fileContent([
[
path.join(appPath + '/scripts', targetDirectory, name + '.js'),
new RegExp(
@@ -147,7 +148,7 @@ describe('Angular generator appPath option', function () {
helpers.mockPrompt(angular, mockPrompts);
angular.run([], function () {
angularView.run([], function () {
- helpers.assertFile([appPath + '/views/foo.html']);
+ assert.file([appPath + '/views/foo.html']);
done();
});
});
@@ -161,7 +162,7 @@ describe('Angular generator appPath option', function () {
helpers.mockPrompt(angular, mockPrompts);
angular.run([], function () {
angularView.run([], function () {
- helpers.assertFile([appPath + '/views/foo/bar.html']);
+ assert.file([appPath + '/views/foo/bar.html']);
done();
});
});
@@ -2,6 +2,7 @@
var path = require('path');
var helpers = require('yeoman-generator').test;
+var assert = require('yeoman-assert');
var _ = require('underscore.string');
describe('Angular generator file creation', function () {
@@ -60,14 +61,14 @@ describe('Angular generator file creation', function () {
describe('App files', function () {
it('should generate dotfiles', function (done) {
angular.run({}, function () {
- helpers.assertFile(expected);
+ assert.file(expected);
done();
});
});
it('creates expected JS files', function (done) {
angular.run({}, function() {
- helpers.assertFile([].concat(expected, [
+ assert.file([].concat(expected, [
'.jscsrc',
'app/scripts/app.js',
'app/scripts/controllers/main.js',
@@ -80,7 +81,7 @@ describe('Angular generator file creation', function () {
it('creates CoffeeScript files', function (done) {
angular.env.options.coffee = true;
angular.run([], function () {
- helpers.assertFile([].concat(expected, [
+ assert.file([].concat(expected, [
'app/scripts/app.coffee',
'app/scripts/controllers/main.coffee',
'test/spec/controllers/main.coffee'
@@ -98,7 +99,7 @@ describe('Angular generator file creation', function () {
angular.run([], function () {
genTester.run([], function () {
- helpers.assertFileContent([
+ assert.fileContent([
[
path.join('app/scripts', targetDirectory, name + '.js'),
new RegExp(
@@ -166,7 +167,7 @@ describe('Angular generator file creation', function () {
angular.env.options.typescript = true;
angular.run([], function () {
- helpers.assertFiles(expected);
+ assert.file(expected);
done();
});
});
@@ -180,7 +181,7 @@ describe('Angular generator file creation', function () {
helpers.mockPrompt(angularView, mockPrompts);
angularView.run([], function () {
- helpers.assertFile(['app/views/foo.html']);
+ assert.file(['app/views/foo.html']);
done();
});
});
@@ -192,7 +193,7 @@ describe('Angular generator file creation', function () {
helpers.mockPrompt(angularView, mockPrompts);
angularView.run([], function () {
- helpers.assertFile(['app/views/foo/bar.html']);
+ assert.file(['app/views/foo/bar.html']);
done();
});
});
View
@@ -1,6 +1,6 @@
'use strict';
-var assert = require('yeoman-generator').assert;
+var assert = require('assert');
describe('Angular-Module generator load test', function () {
it('can be imported without blowing up', function () {
@@ -2,6 +2,7 @@
var path = require('path');
var helpers = require('yeoman-generator').test;
+var assert = require('yeoman-assert');
describe('Angular generator route', function () {
var angular;
@@ -64,8 +65,8 @@ describe('Angular generator route', function () {
describe('create routes', function () {
it('should generate default route items', function(done){
angular.run({}, function(e) {
- helpers.assertFile(expected);
- helpers.assertFileContent(
+ assert.file(expected);
+ assert.fileContent(
'app/scripts/app.js',
new RegExp('when\\(\'/' + route + '\'')
);
@@ -80,8 +81,8 @@ describe('Angular generator route', function () {
angular.options.uri = uri;
angular.run({}, function() {
- helpers.assertFile(expected);
- helpers.assertFileContent(
+ assert.file(expected);
+ assert.fileContent(
'app/scripts/app.js',
new RegExp('when\\(\'/' + uri + '\'')
);

0 comments on commit 980d8f0

Please sign in to comment.