├── .meteor ├── .finished-upgraders ├── .gitignore ├── .id ├── packages ├── platforms ├── release └── versions ├── README.md ├── both ├── actions │ └── CounterActions.jsx ├── components │ ├── Counter.jsx │ └── EvenOdd.jsx └── domains │ └── CounterDomain.jsx ├── client ├── main.html ├── main.jsx └── styles.css └── tests └── jasmine └── client └── unit ├── components ├── Counter_spec.js └── EvenOdd_spec.js └── spec_helper.js /.meteor/.finished-upgraders: -------------------------------------------------------------------------------- 1 | # This file contains information which helps Meteor properly upgrade your 2 | # app when you run 'meteor update'. You should check it into version control 3 | # with your project. 4 | 5 | notices-for-0.9.0 6 | notices-for-0.9.1 7 | 0.9.4-platform-file 8 | notices-for-facebook-graph-api-2 9 | -------------------------------------------------------------------------------- /.meteor/.gitignore: -------------------------------------------------------------------------------- 1 | local 2 | -------------------------------------------------------------------------------- /.meteor/.id: -------------------------------------------------------------------------------- 1 | # This file contains a token that is unique to your project. 2 | # Check it into your repository along with the rest of this directory. 3 | # It can be used for purposes such as: 4 | # - ensuring you don't accidentally deploy one app on top of another 5 | # - providing package authors with aggregated statistics 6 | 7 | 1q3uh68w7l5r3r9v0j5 8 | -------------------------------------------------------------------------------- /.meteor/packages: -------------------------------------------------------------------------------- 1 | # Meteor packages used by this project, one per line. 2 | # Check this file (and the other files in this directory) into your repository. 3 | # 4 | # 'meteor add' and 'meteor remove' will edit this file for you, 5 | # but you can also edit it by hand. 6 | 7 | meteor-platform 8 | autopublish 9 | insecure 10 | react 11 | sanjo:jasmine 12 | velocity:html-reporter 13 | reactive-dict 14 | -------------------------------------------------------------------------------- /.meteor/platforms: -------------------------------------------------------------------------------- 1 | server 2 | browser 3 | -------------------------------------------------------------------------------- /.meteor/release: -------------------------------------------------------------------------------- 1 | METEOR@1.1.0.2 2 | -------------------------------------------------------------------------------- /.meteor/versions: -------------------------------------------------------------------------------- 1 | amplify@1.0.0 2 | autopublish@1.0.3 3 | autoupdate@1.2.1 4 | babel-compiler@5.7.3 5 | babel-runtime@0.1.2 6 | base64@1.0.3 7 | binary-heap@1.0.3 8 | blaze@2.1.2 9 | blaze-tools@1.0.3 10 | boilerplate-generator@1.0.3 11 | callback-hook@1.0.3 12 | check@1.0.5 13 | coffeescript@1.0.6 14 | cosmos:browserify@0.4.0 15 | ddp@1.1.0 16 | deps@1.0.7 17 | ejson@1.0.6 18 | fastclick@1.0.3 19 | geojson-utils@1.0.3 20 | html-tools@1.0.4 21 | htmljs@1.0.4 22 | http@1.1.0 23 | id-map@1.0.3 24 | insecure@1.0.3 25 | jquery@1.11.3_2 26 | json@1.0.3 27 | jsx@0.1.3 28 | launch-screen@1.0.2 29 | less@1.0.14 30 | livedata@1.0.13 31 | logging@1.0.7 32 | meteor@1.1.6 33 | meteor-platform@1.2.2 34 | minifiers@1.1.5 35 | minimongo@1.0.8 36 | mobile-status-bar@1.0.3 37 | mongo@1.1.0 38 | observe-sequence@1.0.6 39 | ordered-dict@1.0.3 40 | package-version-parser@3.0.3 41 | practicalmeteor:chai@1.9.2_3 42 | practicalmeteor:loglevel@1.1.0_3 43 | random@1.0.3 44 | react@0.1.3 45 | react-meteor-data@0.1.1 46 | react-runtime@0.13.3_2 47 | react-runtime-dev@0.13.3_2 48 | react-runtime-prod@0.13.3_1 49 | reactive-dict@1.1.0 50 | reactive-var@1.0.5 51 | reload@1.1.3 52 | retry@1.0.3 53 | routepolicy@1.0.5 54 | sanjo:jasmine@0.14.0 55 | sanjo:karma@1.5.1 56 | sanjo:long-running-child-process@1.0.3 57 | sanjo:meteor-files-helpers@1.1.0_6 58 | sanjo:meteor-version@1.0.0 59 | session@1.1.0 60 | spacebars@1.0.6 61 | spacebars-compiler@1.0.6 62 | templating@1.1.1 63 | tracker@1.0.7 64 | ui@1.0.6 65 | underscore@1.0.3 66 | url@1.0.4 67 | velocity:chokidar@1.0.3_1 68 | velocity:core@0.7.1 69 | velocity:html-reporter@0.7.0 70 | velocity:meteor-internals@1.1.0_7 71 | velocity:meteor-stubs@1.1.0 72 | velocity:shim@0.1.0 73 | webapp@1.2.0 74 | webapp-hashing@1.0.3 75 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React Meteor Tests 2 | ### React Unit Tests in Meteor 3 | 4 | - Jasmine Unit Tests 5 | - jQuery based spec helpers 6 | 7 | 8 | #### TODO 9 | - Shallow rendering (without DOM) 10 | - Test Domains (data fetching object) 11 | - Test Actions 12 | - Integration tests 13 | - Mocha 14 | - Jest 15 | - external Karma runner (not in Velocity) 16 | 17 | #### Usage 18 | To run just cd into this repo and run `meteor` 19 | 20 | 21 | This repo shows how to test a very basic React app. Though the app is small it's structured in a way that suits 22 | larger apps. However this makes it easy to test! If you like this layout structure/architecture, keep an eye on [Meteor Generate](https://github.com/AdamBrodzinski/meteor-generate) for a CLI scaffolding tool to *create components with an initial passing spec!* 23 | 24 |  25 | 26 |  27 | -------------------------------------------------------------------------------- /both/actions/CounterActions.jsx: -------------------------------------------------------------------------------- 1 | /*global CounterActions:true */ 2 | 3 | CounterActions = { 4 | incrementCount() { 5 | CounterDomain.handleIncrementCount(1); 6 | console.log('[Actions] incrementCount'); 7 | }, 8 | 9 | decrementCount() { 10 | CounterDomain.handleDecrementCount(1); 11 | console.log('[Actions] decrementCount'); 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /both/components/Counter.jsx: -------------------------------------------------------------------------------- 1 | /* jshint maxlen: false */ 2 | 3 | Counter = React.createClass({ 4 | mixins: [ReactMeteorData], 5 | 6 | getDefaultProps() { 7 | return { foo: true }; 8 | }, 9 | 10 | getInitialState() { 11 | return { isHidden: false }; 12 | }, 13 | 14 | getMeteorData() { 15 | return { 16 | count: CounterDomain.getCount() 17 | }; 18 | }, 19 | 20 | toggleHidden() { 21 | var toggled = !this.state.isHidden; 22 | this.setState({isHidden: toggled}); 23 | }, 24 | 25 | sumTwoNumbers(a, b) { 26 | return a + b; 27 | }, 28 | 29 | handleInc() { 30 | CounterActions.incrementCount(); 31 | }, 32 | 33 | handleDec() { 34 | CounterActions.decrementCount(); 35 | }, 36 | 37 | render() { 38 | return ( 39 |
The count is: { this.data.count }
48 |