├── .gitignore ├── LICENSE ├── README.md ├── examples └── simple │ ├── __tests__ │ └── checklist-test.js │ └── checklist.js ├── package.json └── preprocessor.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Commenting this out is preferred by some people, see 24 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 25 | node_modules 26 | 27 | # Users Environment Variables 28 | .lock-wscript 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 davidmccabe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | react-quickcheck 2 | ================ 3 | 4 | Property-based testing for React components 5 | -------------------------------------------------------------------------------- /examples/simple/__tests__/checklist-test.js: -------------------------------------------------------------------------------- 1 | /** @jsx React.DOM */ 2 | 3 | jest.dontMock('../checklist.js'); 4 | describe('CheckboxWithLabel', function() { 5 | it('changes the text after click', function() { 6 | var React = require('react/addons'); 7 | var CheckboxWithLabel = require('../checklist.js'); 8 | var TestUtils = React.addons.TestUtils; 9 | 10 | // Render a checkbox with label in the document 11 | var checkbox = TestUtils.renderIntoDocument( 12 | 13 | ); 14 | 15 | // Verify that it's Off by default 16 | var label = TestUtils.findRenderedDOMComponentWithTag( 17 | checkbox, 'label'); 18 | expect(label.getDOMNode().textContent).toEqual('Off'); 19 | 20 | // Simulate a click and verify that it is now On 21 | var input = TestUtils.findRenderedDOMComponentWithTag( 22 | checkbox, 'input'); 23 | TestUtils.Simulate.change(input); 24 | expect(label.getDOMNode().textContent).toEqual('On'); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /examples/simple/checklist.js: -------------------------------------------------------------------------------- 1 | /** @jsx React.DOM */ 2 | 3 | // CheckboxWithLabel.js 4 | 5 | var React = require('react/addons'); 6 | var CheckboxWithLabel = React.createClass({ 7 | getInitialState: function() { 8 | return { isChecked: false }; 9 | }, 10 | onChange: function() { 11 | this.setState({isChecked: !this.state.isChecked}); 12 | }, 13 | render: function() { 14 | return ( 15 | 23 | ); 24 | } 25 | }); 26 | module.exports = CheckboxWithLabel; 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-quickcheck", 3 | "version": "0.0.1", 4 | "description": "Property-based testing for React components", 5 | "author": "David McCabe ", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/davidmccabe/react-quickcheck" 9 | }, 10 | "bugs": { 11 | "url": "https://github.com/davidmccabe/react-quickcheck/issues" 12 | }, 13 | "keywords": [ 14 | "react", 15 | "test", 16 | "testing", 17 | "unit", 18 | "quickcheck" 19 | ], 20 | "private": true, 21 | "license": "MIT", 22 | "devDependencies": { 23 | "jest-cli": "^0.2.0", 24 | "jsverify": "^0.4.6", 25 | "react": "^0.12.1", 26 | "react-tools": "^0.12.1" 27 | }, 28 | "jest": { 29 | "scriptPreprocessor": "/preprocessor.js", 30 | "unmockedModulePathPatterns": [ 31 | "/node_modules/react" 32 | ] 33 | }, 34 | "scripts": { 35 | "test": "node node_modules/.bin/jest" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /preprocessor.js: -------------------------------------------------------------------------------- 1 | // preprocessor.js 2 | var ReactTools = require('react-tools'); 3 | module.exports = { 4 | process: function(src) { 5 | return ReactTools.transform(src); 6 | } 7 | }; 8 | --------------------------------------------------------------------------------