generator-bitch
Version:
A simple generator (for Yeoman) to scaffolding web applications, just frontend stack
572 lines (517 loc) • 11.9 kB
JavaScript
import {test, assert} from 'yeoman-generator'
const packageJSON = require(`${process.env.PWD}/package.json`)
const generator = `${process.env.PWD}/${packageJSON.main}`
describe('generate a scaffolding', scaffolding)
function scaffolding() {
describe('pure javascript', noFrameworkJavascriptTests)
describe('angular', angularTests)
}
function noFrameworkJavascriptTests() {
it('pug, sass', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'pug',
preprocessor: 'sass',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('pug, less', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'pug',
preprocessor: 'less',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('pug, stylus', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'pug',
preprocessor: 'stylus',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('ejs, sass', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'ejs',
preprocessor: 'sass',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('ejs, less', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'ejs',
preprocessor: 'less',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('ejs, stylus', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'ejs',
preprocessor: 'stylus',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('html, sass', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'html',
preprocessor: 'sass',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('html, less', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'html',
preprocessor: 'less',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
it('html, stylus', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'html',
preprocessor: 'stylus',
appFramework: 'none',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/watch.js',
'package.json',
'public',
// 'test'
'sources/scripts',
])
assert.noFile([
'karma.js',
'sources/angular',
'tasks/templates.js',
])
done()
}
})
}
function angularTests() {
it('uiRouter', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'pug',
preprocessor: 'sass',
appFramework: 'angular',
frameworkModules: [
'ngAnimate',
'ngCookies',
'ngResource',
'ngSanitize',
'ngTouch',
],
angularRoute: 'uiRouter',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/templates.js',
'tasks/watch.js',
'package.json',
'public',
// 'test',
'sources/angular',
'karma.js',
])
done()
}
})
it('ngRoute', done => {
const prompts = {
appName: 'lorem',
viewEngine: 'pug',
preprocessor: 'sass',
appFramework: 'angular',
frameworkModules: [
'ngAnimate',
'ngCookies',
'ngResource',
'ngSanitize',
'ngTouch',
],
angularRoute: 'ngRoute',
}
test
.run(generator)
.withPrompts(prompts)
.on('end', assertion)
function assertion() {
assert.file([
'README.md',
'.yo-rc.json',
'.babelrc',
'.editorconfig',
'.gitignore',
'.eslintrc.js',
'sources',
'gulpfile.babel.js',
'tasks/default.js',
'tasks/config.js',
'tasks/lint.js',
'tasks/browser-sync.js',
'tasks/scripts.js',
'tasks/sprite-images.js',
'tasks/styles.js',
'tasks/vendorCSS.js',
'tasks/vendorJS.js',
'tasks/views.js',
'tasks/templates.js',
'tasks/watch.js',
'package.json',
'public',
// 'test',
'sources/angular',
'karma.js',
])
done()
}
})
}