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 renderer from 'react-test-renderer' | |
import App from '../App' | |
// Generated snapshot is exactly like the previous example | |
// while it's possible to override the default mock | |
// by using the same jest.mock command as before | |
// if this test need a different behavior than the | |
// glboal mock. | |
it('should render correctly', () => { |
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
{ | |
"jest": { | |
"setupFiles": [ | |
"<rootDir>/test-setup.js" | |
] | |
} | |
} |
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
{ | |
"jest": { | |
"setupFiles": [ | |
"<rootDir>/test-setup.js" | |
] | |
} | |
} |
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 renderer from 'react-test-renderer' | |
import Input from '../Input' | |
it('should render correctly', () => { | |
const component = renderer.create(<Input />) | |
expect(component.toJSON()).toMatchSnapshot() | |
// getInstance is returning the `this` object you have in your component | |
// meaning anything accessible on `this` inside your component | |
// can be accessed on getInstance, including props! |
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 renderer from 'react-test-renderer' | |
import NotificationsContainer from '../NotificationsContainer' | |
// we can just pass through the component since we pass dispatch prop directly | |
jest.mock('react-redux', () => component => component) | |
it('should render correctly', () => { | |
const dispatch = jest.fn() | |
const component = renderer.create( | |
<NotificationsContainer dispatch={dispatch} /> |
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 renderer from 'react-test-renderer' | |
import Form, { validate } from '../Form' | |
jest.mock('redux-form', () => ({ | |
Field: 'Field', | |
reduxForm: options => { | |
// Wrap the component and return the new component, just like the real hoc does | |
return Form => props => { | |
// call the validate error to make sure errors are detected | |
options.validate({}, props) |
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 renderer from 'react-test-renderer' | |
import Canvas from '../Canvas' | |
it('should render correctly', () => { | |
const component = renderer.create(<Form x={0} y={0} />) | |
expect(component.toJSON()).toMatchSnapshot() | |
const instance = component.getInstance() | |
const spy = jest.spyOn(instance, 'calculateGrid') |
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 renderer from 'react-test-renderer' | |
import Viewport from '../Viewport' | |
it('should render correctly', () => { | |
const target = { | |
innerHeight: 600, | |
innerWidth: 800, | |
addEventListener: jest.fn(), | |
removeEventListener: jest.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
import renderer from 'react-test-renderer' | |
import Field from '../Field' | |
// this import is created by our mock, it is inteded to help with testing and | |
// don't exist in the real package | |
import { intl } from 'react-intl' | |
it('should render correctly', () => { | |
const component = renderer.create(<Field intl={intl} />) | |
expect(component.toJSON()).toMatchSnapshot() |
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
public class Constants { | |
/** | |
* Contains the path to your Lambda function code. | |
*/ | |
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT"); | |
/** | |
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function: | |
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10 |