Chore: Added new version of dependencies

This commit is contained in:
Chris 2016-05-17 08:02:17 +02:00
parent 0f6d9158be
commit cc0172086f
3 changed files with 130 additions and 102 deletions

View File

@ -1,5 +1,9 @@
# generator-react-webpack - Changelog # generator-react-webpack - Changelog
## 3.3.1
1. Added new version of yeoman-generator, adjusted unit tests
## 3.3.0 ## 3.3.0
1. Added new yeoman key "generatedWithVersion". Will be used for backwards compatibility of new major releases. 1. Added new yeoman key "generatedWithVersion". Will be used for backwards compatibility of new major releases.

View File

@ -42,7 +42,7 @@
"dependencies": { "dependencies": {
"react-webpack-template": "^1.0.0", "react-webpack-template": "^1.0.0",
"underscore.string": "^3.2.2", "underscore.string": "^3.2.2",
"yeoman-generator": "^0.22.0", "yeoman-generator": "^0.23.0",
"yeoman-welcome": "^1.0.1", "yeoman-welcome": "^1.0.1",
"esprima": "^2.7.0", "esprima": "^2.7.0",
"esprima-walk": "^0.1.0", "esprima-walk": "^0.1.0",

View File

@ -6,27 +6,23 @@ let helpers = require('yeoman-test');
// Default globals, used in all tests // Default globals, used in all tests
const defaultPrompts = require('../../../generators/app/prompts.js'); const defaultPrompts = require('../../../generators/app/prompts.js');
let generator;
const generatorBase = path.join(__dirname, '../../../generators/app'); const generatorBase = path.join(__dirname, '../../../generators/app');
/** /**
* Global before load function. Run in the before callbacks * Global before load function. Run in the before callbacks
* @param {Object} prompts List of prompts to use * @param {Object} prompts List of prompts to use
* @param {Function} done Done callback * @return {Promise}
*/ */
const beforeLoad = (prompts, done) => { const beforeLoad = (prompts) => {
helpers.run(generatorBase) return helpers.run(generatorBase)
.inTmpDir() .inTmpDir()
.withOptions({ .withOptions({
'skip-welcome-message': true, 'skip-welcome-message': true,
'skip-install': true 'skip-install': true
}) })
.withPrompts(prompts) .withPrompts(prompts)
.on('ready', (instance) => { .toPromise();
generator = instance;
})
.on('end', done);
}; };
describe('react-webpack:app', () => { describe('react-webpack:app', () => {
@ -36,22 +32,24 @@ describe('react-webpack:app', () => {
prompts[p.name] = p.default; prompts[p.name] = p.default;
} }
before((done) => {
beforeLoad(prompts, done);
});
describe('#config', () => { describe('#config', () => {
it('should set the generatedWith key to the current generator major version', () => { it('should set the generatedWith key to the current generator major version', () => {
expect(generator.config.get('generatedWithVersion')).to.equal(3); beforeLoad(prompts).then((generator) => {
expect(generator.config.get('generatedWithVersion')).to.equal(3);
});
}); });
it('should use "css" as default style language', () => { it('should use "css" as default style language', () => {
expect(generator.config.get('style')).to.equal('css'); beforeLoad(prompts).then((generator) => {
expect(generator.config.get('style')).to.equal('css');
});
}); });
it('should not enable "PostCSS" by default', () => { it('should not enable "PostCSS" by default', () => {
expect(generator.config.get('postcss')).to.equal(false); beforeLoad(prompts).then((generator) => {
expect(generator.config.get('postcss')).to.equal(false);
});
}); });
}); });
@ -59,58 +57,68 @@ describe('react-webpack:app', () => {
it('should generate dot files', () => { it('should generate dot files', () => {
assert.file([ beforeLoad(prompts).then(() => {
'.babelrc', assert.file([
'.editorconfig', '.babelrc',
'.eslintrc', '.editorconfig',
'.gitignore', '.eslintrc',
'.yo-rc.json' '.gitignore',
]); '.yo-rc.json'
]);
});
}); });
it('should generate project configuration files', () => { it('should generate project configuration files', () => {
assert.file([ beforeLoad(prompts).then(() => {
'package.json' assert.file([
]); 'package.json'
]);
});
}); });
it('should generate the webpack configuration', () => { it('should generate the webpack configuration', () => {
assert.file([ beforeLoad(prompts).then(() => {
'cfg/base.js', assert.file([
'cfg/defaults.js', 'cfg/base.js',
'cfg/dev.js', 'cfg/defaults.js',
'cfg/dist.js', 'cfg/dev.js',
'cfg/test.js', 'cfg/dist.js',
'server.js', 'cfg/test.js',
'webpack.config.js' 'server.js',
]); 'webpack.config.js'
]);
});
}); });
it('should generate required source files', () => { it('should generate required source files', () => {
assert.file([ beforeLoad(prompts).then(() => {
'src/actions/README.md', assert.file([
'src/index.js', 'src/actions/README.md',
'src/components/Main.js', 'src/index.js',
'src/favicon.ico', 'src/components/Main.js',
'src/images/yeoman.png', 'src/favicon.ico',
'src/index.html', 'src/images/yeoman.png',
'src/sources/README.md', 'src/index.html',
'src/stores/README.md', 'src/sources/README.md',
'src/styles/App.css' 'src/stores/README.md',
]); 'src/styles/App.css'
]);
});
}); });
it('should generate test configuration and basic tests', () => { it('should generate test configuration and basic tests', () => {
assert.file([ beforeLoad(prompts).then(() => {
'karma.conf.js', assert.file([
'test/components/MainTest.js', 'karma.conf.js',
'test/helpers/shallowRenderHelper.js', 'test/components/MainTest.js',
'test/loadtests.js' 'test/helpers/shallowRenderHelper.js',
]); 'test/loadtests.js'
]);
});
}); });
}); });
}); });
@ -124,22 +132,24 @@ describe('react-webpack:app with PostCSS support', () => {
prompts.postcss = true; prompts.postcss = true;
before((done) => {
beforeLoad(prompts, done);
});
describe('#config', () => { describe('#config', () => {
it('should set the generatedWith key to the current generator major version', () => { it('should set the generatedWith key to the current generator major version', () => {
expect(generator.config.get('generatedWithVersion')).to.equal(3); beforeLoad(prompts).then((generator) => {
expect(generator.config.get('generatedWithVersion')).to.equal(3);
});
}); });
it('should use "css" as default style language', () => { it('should use "css" as default style language', () => {
expect(generator.config.get('style')).to.equal('css'); beforeLoad(prompts).then((generator) => {
expect(generator.config.get('style')).to.equal('css');
});
}); });
it('should enable "PostCSS"', () => { it('should enable "PostCSS"', () => {
expect(generator.config.get('postcss')).to.equal(true); beforeLoad(prompts).then((generator) => {
expect(generator.config.get('postcss')).to.equal(true);
});
}); });
}); });
@ -147,72 +157,86 @@ describe('react-webpack:app with PostCSS support', () => {
it('should generate dot files', () => { it('should generate dot files', () => {
assert.file([ beforeLoad(prompts).then(() => {
'.babelrc', assert.file([
'.editorconfig', '.babelrc',
'.eslintrc', '.editorconfig',
'.gitignore', '.eslintrc',
'.yo-rc.json' '.gitignore',
]); '.yo-rc.json'
]);
});
}); });
it('should generate project configuration files', () => { it('should generate project configuration files', () => {
assert.file([ beforeLoad(prompts).then(() => {
'package.json' assert.file([
]); 'package.json'
]);
});
}); });
it('should generate the webpack configuration', () => { it('should generate the webpack configuration', () => {
assert.file([ beforeLoad(prompts).then(() => {
'cfg/base.js', assert.file([
'cfg/defaults.js', 'cfg/base.js',
'cfg/dev.js', 'cfg/defaults.js',
'cfg/dist.js', 'cfg/dev.js',
'cfg/test.js', 'cfg/dist.js',
'server.js', 'cfg/test.js',
'webpack.config.js' 'server.js',
]); 'webpack.config.js'
]);
});
}); });
it('should insert the postcss loader into the style pipes', () => { it('should insert the postcss loader into the style pipes', () => {
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader\''); beforeLoad(prompts).then(() => {
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded&indentedSyntax\''); assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader\'');
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded\''); assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded&indentedSyntax\'');
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!less-loader\''); assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!sass-loader?outputStyle=expanded\'');
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!stylus-loader\''); assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!less-loader\'');
assert.fileContent('cfg/defaults.js', 'loader: \'style-loader!css-loader!postcss-loader!stylus-loader\'');
});
}); });
it('should append the postcss function to the base config', () => { it('should append the postcss function to the base config', () => {
assert.fileContent('cfg/defaults.js', ',\n postcss: function () {\n return [];\n }'); beforeLoad(prompts).then(() => {
assert.fileContent('cfg/defaults.js', ',\n postcss: function () {\n return [];\n }');
});
}); });
it('should generate required source files', () => { it('should generate required source files', () => {
assert.file([ beforeLoad(prompts).then(() => {
'src/actions/README.md', assert.file([
'src/index.js', 'src/actions/README.md',
'src/components/Main.js', 'src/index.js',
'src/favicon.ico', 'src/components/Main.js',
'src/images/yeoman.png', 'src/favicon.ico',
'src/index.html', 'src/images/yeoman.png',
'src/sources/README.md', 'src/index.html',
'src/stores/README.md', 'src/sources/README.md',
'src/styles/App.css' 'src/stores/README.md',
]); 'src/styles/App.css'
]);
});
}); });
it('should generate test configuration and basic tests', () => { it('should generate test configuration and basic tests', () => {
assert.file([ beforeLoad(prompts).then(() => {
'karma.conf.js', assert.file([
'test/components/MainTest.js', 'karma.conf.js',
'test/helpers/shallowRenderHelper.js', 'test/components/MainTest.js',
'test/loadtests.js' 'test/helpers/shallowRenderHelper.js',
]); 'test/loadtests.js'
]);
});
}); });
}); });
}); });