mirror of
https://github.com/react-webpack-generators/generator-react-webpack.git
synced 2025-12-08 18:01:59 +00:00
commit 25ef9a176ee9bab902579f79415bd6047a77a62f
Author: Simon Bailey <simon@newtriks.com>
Date: Thu May 15 19:51:45 2014 +0100
Updated README
Signed-off-by: Simon Bailey <simon@newtriks.com>
commit 1b0020c8fd248bc0dc892bed1f3e315867378274
Merge: d8fd494 c468b98
Author: Edd <accounts@edd.fm>
Date: Sat Apr 26 11:13:52 2014 +0100
Merged with Master
commit d8fd494478cb7fd0d97a47a90986f4c1b29eb996
Author: Edd <accounts@edd.fm>
Date: Thu Apr 24 22:09:19 2014 +0100
Trimming redundant options from Gruntfile
commit b5015ae42b0beb770ae1b146f152b5f38764987e
Author: Edd <accounts@edd.fm>
Date: Sun Mar 30 21:32:14 2014 +0100
Moved development mode to webpack-dev-server to imrove rebuild times
commit 7d31ade8085a8d415b95c67dba69ae5157ebf9b4
Author: Edd <accounts@edd.fm>
Date: Wed Feb 26 00:18:56 2014 +0000
Changed JSX filenames to .jsx over .js
commit 00faa6182b6cb4ae46b05dd12db1e73da4b47953
Author: Edd <accounts@edd.fm>
Date: Mon Feb 24 23:39:18 2014 +0000
Updated engines & Travis build targets
commit e58e0d70639f3c3e9acc7d085b6a795365a140a6
Author: Edd <accounts@edd.fm>
Date: Mon Feb 24 23:26:04 2014 +0000
Added auto generation of a template CSS file for a component
commit f6c67351aead570224b2457261d457a1954277dc
Author: Edd <accounts@edd.fm>
Date: Mon Feb 24 00:06:42 2014 +0000
Updated default app test
commit 996d769685d1a4f20ae2c4117422790bbc347594
Author: Edd <accounts@edd.fm>
Date: Sun Feb 23 23:32:37 2014 +0000
Added test for default main component (currently identical to any other component tests)
commit 31dfcbaff6ee9aef339886897e053a339f98021b
Author: Edd <accounts@edd.fm>
Date: Sun Feb 23 22:54:04 2014 +0000
Moved webpack configuration to a separate file
- Added webpack config file
- Added Uglify to webpack config
- Added source maps in webpack config
Moved entry file back in to Gruntfile
commit 6b3a3e92b80f3121e1128e4f166cf36aa32cfa26
Author: Edd <accounts@edd.fm>
Date: Sun Feb 23 17:23:07 2014 +0000
Added distribution folder & Grunt tasks to deal with it
- Created Distribution build folder (script link broken)
- Added grunt-contrib-copy
- Added grunt-uglify
- Bumped React version number
- Switched source map types
Signed-off-by: Simon Bailey <simon@newtriks.com>
104 lines
4.0 KiB
JavaScript
104 lines
4.0 KiB
JavaScript
/*global describe, beforeEach, it*/
|
|
'use strict';
|
|
|
|
var path = require('path');
|
|
var helpers = require('yeoman-generator').test;
|
|
var _ = require('underscore.string');
|
|
|
|
describe('react-webpack generator', function () {
|
|
var react;
|
|
|
|
beforeEach(function (done) {
|
|
var deps = [
|
|
'../../app',
|
|
'../../common',
|
|
'../../component',
|
|
'../../main'
|
|
];
|
|
helpers.testDirectory(path.join(__dirname, 'temp-test'), function (err) {
|
|
if (err) {
|
|
return done(err);
|
|
}
|
|
|
|
react = helpers.createGenerator('react-webpack:app', deps);
|
|
react.options['skip-install'] = true;
|
|
done();
|
|
}.bind(this));
|
|
});
|
|
|
|
it('should generate dotfiles', function (done) {
|
|
react.run({}, function () {
|
|
helpers.assertFiles(['.gitignore', '.editorconfig', '.jshintrc']);
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('creates expected files', function (done) {
|
|
var expected = ['src/favicon.ico',
|
|
'src/styles/reset.css',
|
|
'src/styles/main.css',
|
|
'src/index.html',
|
|
'Gruntfile.js',
|
|
'webpack.config.js',
|
|
'karma.conf.js',
|
|
'package.json',
|
|
'package.json',
|
|
'src/scripts/components/TempTestApp.jsx',
|
|
'test/helpers/phantomjs-shims.js',
|
|
'test/helpers/react/addons.js',
|
|
'test/spec/components/TempTestApp.js',
|
|
];
|
|
|
|
react.run({}, function () {
|
|
helpers.assertFiles(expected);
|
|
done();
|
|
});
|
|
});
|
|
|
|
/**
|
|
* Generic test function that can be used to cover the scenarios where a generator is creating both a source file
|
|
* and a test file. The function will run the respective generator, and then check for the existence of the two
|
|
* generated files. A RegExp check is done on each file, checking for the generated content with a pattern.
|
|
*
|
|
* The number of parameters is quite huge due to the many options in which the generated files differ,
|
|
* e.g. Components start with an upper case letter.
|
|
*
|
|
* The generated items all use the dummy name 'foo'.
|
|
*
|
|
* @param generatorType The type of generator to run, e.g. 'component'.
|
|
* @param specType The type of the generated spec file, e.g. 'component'.
|
|
* @param targetDirectory The directory into which the files are generated, e.g. 'components' - this will be
|
|
* located under 'src/scripts/components' for the sources and 'test/spec/components' for the tests.
|
|
* @param scriptNameFn The function used to create the name of the created item, e.g. _.classify to generate 'Foo',
|
|
* or _.camelize to generate 'foo'.
|
|
* @param specNameFn Same as scriptNameFn, but for the describe text used in the Spec file. Some generators use
|
|
* _.classify, others use _.camelize.
|
|
* @param suffix An optional suffix to be appended to the generated item name.
|
|
* @param done The done function.
|
|
*/
|
|
|
|
function generatorTest(generatorType, specType, targetDirectory, scriptNameFn, specNameFn, suffix, done) {
|
|
var reactGenerator;
|
|
var name = 'Foo';
|
|
var deps = [path.join('../..', generatorType)];
|
|
reactGenerator = helpers.createGenerator('react-webpack:' + generatorType, deps, [name]);
|
|
react.run([], function () {
|
|
//var Foo = React.createClass({
|
|
reactGenerator.run([], function () {
|
|
helpers.assertFiles([
|
|
[path.join('src/scripts', targetDirectory, name + '.jsx'), new RegExp('var ' + scriptNameFn(name) + suffix, 'g')],
|
|
[path.join('test/spec', targetDirectory, name + '.js'), new RegExp('describe\\(\'' + specNameFn(name) + suffix + '\'', 'g')]
|
|
]);
|
|
done();
|
|
});
|
|
});
|
|
}
|
|
|
|
describe('Component', function () {
|
|
it('should generate a new component', function (done) {
|
|
generatorTest('component', 'component', 'components', _.capitalize, _.capitalize, '', done);
|
|
});
|
|
});
|
|
|
|
});
|