*FEATURE*: Unittests: Added support for React ShallowRendering as described in http://simonsmith.io/unit-testing-react-components-without-a-dom/.

This commit is contained in:
Chris
2015-07-01 08:50:32 +02:00
parent 62dda60bad
commit b0b0f3f84d
16 changed files with 129 additions and 85 deletions
+3 -5
View File
@@ -85,7 +85,8 @@ describe('react-webpack generator', function() {
// files not present at point of test...
setTimeout(function() {
helpers.assertFile([].concat(expected, [
'test/helpers/phantomjs-shims.js',
'test/helpers/pack/phantomjs-shims.js',
'test/helpers/createComponent.js',
'test/helpers/react/addons.js',
'test/spec/components/TempTestApp.js'
]));
@@ -235,7 +236,6 @@ describe('react-webpack generator', function() {
describe('When generating a Component', function() {
var generatorTest = function(name, generatorType, specType, targetDirectory, scriptNameFn, specNameFn, suffix, done) {
var deps = [path.join('../..', generatorType)];
genOptions.appPath = 'src';
@@ -244,13 +244,11 @@ describe('react-webpack generator', function() {
react.run([], function() {
reactGenerator.run([], function() {
helpers.assertFileContent([
[path.join('src', targetDirectory, name + '.js'), new RegExp('var ' + scriptNameFn(name) + suffix, 'g')],
[path.join('src', targetDirectory, name + '.js'), new RegExp('require\\(\'styles\\/' + name + suffix + '\\.[^\']+' + '\'\\)', 'g')],
[path.join('test/spec', targetDirectory, 'TempTestApp' + '.js'), new RegExp('require\\(\'components\\/' + 'TempTestApp' + suffix + '\\.[^\']+' + '\'\\)', 'g')],
[path.join('test/spec', targetDirectory, name + '.js'), new RegExp('require\\(\'components\\/' + name + suffix + '\\.[^\']+' + '\'\\)', 'g')],
[path.join('test/spec', targetDirectory, name + '.js'), new RegExp('import ' + scriptNameFn(name) + ' from \'components\/Foo', 'g')],
[path.join('test/spec', targetDirectory, name + '.js'), new RegExp('describe\\(\'' + specNameFn(name) + suffix + '\'', 'g')]
]);
done();
});