This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Root.js | |
| const Root = () => | |
| <Router> | |
| <Route component={UserScene} path="/users/:userId" /> | |
| </Router>; | |
| export default Root; | |
| // UserDetailsScene.js | |
| const USER_DETAILS_FRAGMENT = gql` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // @flow | |
| import { mount, shallow } from 'enzyme'; | |
| import enzymeSnapshotSerializer from 'enzyme-to-json/serializer'; | |
| import { noop } from 'lodash/fp'; | |
| import React from 'react'; | |
| import { snapshotSerializer as apolloSnapshotSerializer } from 'core/apollo'; | |
| import { snapshotSerializer as graphqlSnapshotSerializer } from 'core/graphql'; | |
| import renderApp from 'test/renderApp'; | |
| import Client from 'test/client'; | |
| import SearchBar, { InnerComponent, SEARCH_BAR_QUERY_DEF } from './SearchBar'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| schema { | |
| query: Query | |
| } | |
| type Query { | |
| accounts: AllAccountsConnection! | |
| organizations: AllOrganizationsConnection! | |
| users: AllUsersConnection! | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { compliment, compose, get } from 'lodash/fp'; | |
| import { connect } from 'react-redux'; | |
| import { branch, renderComponent } from 'recompose'; | |
| const selectIsAuthenticated = state => ({ | |
| isAuthenticated: Boolean(state.currentUser), | |
| }); | |
| const withAuth = compose( | |
| connect(selectAuthorizationStatus), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const offerFormSubmitDecorator = Component => { | |
| return connect( | |
| state => ({ offerID: state.offer.get('pk') }), | |
| dispatch => ({ patchOfferCall: (offerId, values) => dispatch(actions.patchOfferCall(offerId, values)) }), | |
| (stateProps, dispatchProps) => ({ | |
| ...stateProps, | |
| onSubmit: values => dispatchProps.patchOfferCall(stateProps.offerId, values), | |
| }) | |
| ) | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component, PropTypes } from 'react' | |
| export class UserDetail extends Component { | |
| static propTypes = { | |
| fetchUser: PropTypes.func.isRequired, | |
| record: PropTypes.object, | |
| } | |
| componentWillMount() { | |
| if (!this.props.record) this.props.fetchUser(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import * as actions from './actions'; | |
| const dispatch = spy(); | |
| const getState = () => ({ | |
| ...your mocked state | |
| }); | |
| describe('Action A', () => { | |
| it('should dispatch a correctly formatted action', () => { | |
| actions.actionA('first arg', 'second arg')(dispatch, getState); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let MAX = 10; | |
| let COUNTER = 0; | |
| export const increment = count => { count += 1 }; | |
| const myObject = { | |
| myFn: () => { | |
| increment(COUNTER); | |
| if(condition) helpers.fn(); | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export class SignupControl extends React.Component { | |
| constructor(props) { | |
| super(props) | |
| this.handleSubmit = this.handleSubmit.bind(this) | |
| } | |
| handleSubmit(values) { | |
| return new Promise ((resolve, reject) => { | |
| this.props.actions.signup(values.name, | |
| values.email, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const webpack = require('webpack'); | |
| const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
| const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
| const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
| const LodashModuleReplacementPlugin = require('lodash-webpack-plugin'); | |
| const autoprefixer = require('autoprefixer'); | |
| const argv = require('yargs').argv; | |
| const __src = path.join(__dirname, 'src'); |