Skip to content

Commit

Permalink
Merge pull request heilhead#45 from brewsoftware/feature/Jest-UnitTes…
Browse files Browse the repository at this point in the history
…tingFramework

Feature/jest unit testing framework
  • Loading branch information
heilhead committed Apr 18, 2016
2 parents fff2b55 + a790894 commit f1bcbd0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "presets": ["es2015","react"] }
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,11 @@ Returns `true` if each file's mime type is in the `types` array.

## Tests

Not yet implemented.
Tests are written using the Jest unit testing framework by facebook. https://facebook.github.io/jest/

To run the tests simply use the command "npm test". All tests should compile and pass before a pull request is accepted.

For new features please add a new unit test spec to the __tests__ directory. Contributions for existing test specifications are welcome.

## License (MIT)

Expand Down
23 changes: 23 additions & 0 deletions __tests__/RenderTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';
import Form from '../src/Form';

// Note: THere is an issue with react-bootstrap and mocking. For now the whole node_modules directory has been unmocked.
describe('React bootstrap validation compilation test', () => {
var React = require('react');
var TestUtils = require('react-addons-test-utils');

beforeEach(function() {

});

it('Renders Form component correctly.', () => {
// Render into document
TestUtils.renderIntoDocument(<div></div>);
TestUtils.renderIntoDocument(
<Form onValidSubmit={ function(event)
{
// Do some work with the validation outcomes
}
} />);
});
});
19 changes: 18 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,32 @@
"peerDependencies": {
"react": ">=0.13"
},
"scripts": {
"test": "jest"
},
"jest": {
"scriptPreprocessor": "node_modules/babel-jest",
"unmockedModulePathPatterns": [
"node_modules",
"src"
]
},
"devDependencies": {
"babel": "^5.6.23",
"babel": "^6.5.2",
"babel-jest": "^10.0.1",
"babel-preset-es2015": "^6.6.0",
"babel-preset-jest": "^10.0.1",
"babel-preset-react": "^6.5.0",
"browserify": "10.x",
"gulp": "3.9.0",
"gulp-babel": "^5.1.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.6",
"jest": "^0.1.40",
"jest-cli": "^0.10.0",
"react-addons-test-utils": "^0.14.8",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"webpack": "^1.10.5"
Expand Down

0 comments on commit f1bcbd0

Please sign in to comment.