forked from yeoman/generator-angular
-
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.
chore(tests): refactor subgens tests
Split up test for subgenerators in their own files
- Loading branch information
1 parent
7436702
commit ccc75da
Showing
14 changed files
with
364 additions
and
210 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,83 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
var _ = require('underscore.string'); | ||
|
||
describe('Angular generator appPath option', function () { | ||
var appPath = 'customAppPath'; | ||
var expected = [ | ||
appPath + '/404.html', | ||
appPath + '/favicon.ico', | ||
appPath + '/robots.txt', | ||
appPath + '/styles/main.scss', | ||
appPath + '/views/main.html', | ||
appPath + '/index.html', | ||
'.bowerrc', | ||
'.editorconfig', | ||
'.gitignore', | ||
'.jshintrc', | ||
'Gruntfile.js', | ||
'package.json', | ||
'bower.json' | ||
]; | ||
|
||
beforeEach(function () { | ||
this.angular = helpers | ||
.run(require.resolve('../app')) | ||
.withGenerators([ | ||
require.resolve('../common'), | ||
require.resolve('../controller'), | ||
require.resolve('../main'), | ||
[helpers.createDummyGenerator(), 'karma:app'] | ||
]) | ||
.withOptions({ | ||
'appPath': appPath, | ||
'skip-welcome-message': true, | ||
'skip-message': true | ||
}) | ||
.withArguments(['upperCaseBug']) | ||
.withPrompts({ | ||
compass: true, | ||
bootstrap: true, | ||
compassBootstrap: true, | ||
modules: [] | ||
}); | ||
}); | ||
|
||
describe('default settings', function () { | ||
beforeEach(function (done) { | ||
this.angular.on('end', done); | ||
}); | ||
|
||
it('generates base files inside the appPath', function () { | ||
assert.file(expected); | ||
}); | ||
|
||
it('creates JS files in appPath', function () { | ||
assert.file([ | ||
'.jscsrc', | ||
appPath + '/scripts/app.js', | ||
appPath + '/scripts/controllers/main.js', | ||
'test/spec/controllers/main.js' | ||
]); | ||
}); | ||
}); | ||
|
||
describe('--coffee', function () { | ||
beforeEach(function (done) { | ||
this.angular.withOptions({ | ||
coffee: true | ||
}).on('end', done); | ||
}); | ||
|
||
it('creates CoffeeScript files', function () { | ||
assert.file([].concat(expected, [ | ||
appPath + '/scripts/app.coffee', | ||
appPath + '/scripts/controllers/main.coffee', | ||
'test/spec/controllers/main.coffee' | ||
])); | ||
}); | ||
}); | ||
}); |
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 fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:constant', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../constant')) | ||
.withArguments('foo') | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new constant', function () { | ||
assert.file('test/spec/services/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/services/foo.js'), | ||
/constant\('foo'/ | ||
); | ||
}); | ||
}); |
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,28 @@ | ||
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:controller', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../controller')) | ||
.withArguments('foo') | ||
.inTmpDir(function (dir) { | ||
fs.writeFileSync( | ||
path.join(dir, 'bower.json'), | ||
'{"appPath": "app"}' | ||
); | ||
}) | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new controller', function () { | ||
assert.file('test/spec/controllers/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/controllers/foo.js'), | ||
/controller\('FooCtrl'/ | ||
); | ||
}); | ||
}); |
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,28 @@ | ||
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:directive', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../directive')) | ||
.withArguments('foo') | ||
.inTmpDir(function (dir) { | ||
fs.writeFileSync( | ||
path.join(dir, 'bower.json'), | ||
'{"appPath": "app"}' | ||
); | ||
}) | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new directive', function () { | ||
assert.file('test/spec/directives/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/directives/foo.js'), | ||
/directive\('foo'/ | ||
); | ||
}); | ||
}); |
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 fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:factory', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../factory')) | ||
.withArguments('foo') | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new factory', function () { | ||
assert.file('test/spec/services/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/services/foo.js'), | ||
/factory\('foo'/ | ||
); | ||
}); | ||
}); |
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,28 @@ | ||
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:filter', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../filter')) | ||
.withArguments('foo') | ||
.inTmpDir(function (dir) { | ||
fs.writeFileSync( | ||
path.join(dir, 'bower.json'), | ||
'{"appPath": "app"}' | ||
); | ||
}) | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new filter', function () { | ||
assert.file('test/spec/filters/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/filters/foo.js'), | ||
/filter\('foo'/ | ||
); | ||
}); | ||
}); |
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 fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:provider', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../provider')) | ||
.withArguments('foo') | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new provider', function () { | ||
assert.file('test/spec/services/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/services/foo.js'), | ||
/provider\('foo'/ | ||
); | ||
}); | ||
}); |
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,28 @@ | ||
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var helpers = require('yeoman-test'); | ||
var assert = require('yeoman-assert'); | ||
|
||
describe('angular:service', function () { | ||
beforeEach(function (done) { | ||
helpers | ||
.run(require.resolve('../service')) | ||
.withArguments('foo') | ||
.inTmpDir(function (dir) { | ||
fs.writeFileSync( | ||
path.join(dir, 'bower.json'), | ||
'{"appPath": "app"}' | ||
); | ||
}) | ||
.on('end', done); | ||
}); | ||
|
||
it('generates a new service', function () { | ||
assert.file('test/spec/services/foo.js'); | ||
assert.fileContent( | ||
path.join('app/scripts/services/foo.js'), | ||
/service\('foo'/ | ||
); | ||
}); | ||
}); |
Oops, something went wrong.