Skip to content

Instantly share code, notes, and snippets.

View jvanderen1's full-sized avatar
🏋️‍♂️

Joshua Van Deren jvanderen1

🏋️‍♂️
  • Google, Inc.
  • Boulder, CO
View GitHub Profile
class TestPage extends React.PureComponent {
//
// Instance methods
fillTable = () => {
const {
tableValues,
} = this.state;
return (
// Libraries
import React from 'react';
import PropTypes from 'prop-types';
// Components
import ButtonComponent from '../component/button-component/Button-Component';
import NumericInputComponent from '../component/input-component/Numeric-Input-Component';
import TableCellComponent from '../component/table-component/Table-Cell-Component';
import TableComponent from '../component/table-component/Table-Component';
import TableRowComponent from '../component/table-component/Table-Row-Component';
// Context
describe('Interaction', () => {
let root;
let instance;
beforeEach(() => {
component = getComponent();
root = component.root;
instance = root.instance;
});
describe('Lifecycle', () => {
let instance;
let newComponent;
const updateComponent = (props) => (
<TestPage {...{ ...defaultProps, ...props }} />
);
beforeEach(() => {
component = getComponent();
instance = component.root.instance;
describe('Rendering', () => {
it('renders default correctly', () => {
component = getComponent();
expect(component).toMatchSnapshot();
});
it('renders no data correctly', () => {
component = getComponent({ numCols: null, numRows: null });
expect(component).toMatchSnapshot();
});
const component = getComponent({
numCols: 10,
});
const instance = component.root.instance;
console.log(instance.props.numCols); // 10
console.log(instance.props.numRows); // 2
const defaultProps = {
numCols: 2,
numRows: 2,
setNumRows: jest.fn(),
setNumCols: jest.fn(),
};
//
const getComponent = (props) => renderer.create(
jest.mock('app/component/button-component/Button-Component', () => 'ButtonComponent');
jest.mock('app/component/input-component/Numeric-Input-Component', () => 'NumericInputComponent');
jest.mock('app/component/table-component/Table-Cell-Component', () => 'TableCellComponent');
jest.mock('app/component/table-component/Table-Component', () => 'TableComponent');
jest.mock('app/component/table-component/Table-Row-Component', () => 'TableRowComponent');
// Imports
// -------
// Libraries
import React from 'react';
import renderer from 'react-test-renderer';
// Components
import { MyComponent } from '.../My-Component';
// Mocks
export {
TestPage,
};
// Default export
export default (
withDatastore(
hasError()(
hasLoader()(TestPage),
),