Skip to content

Instantly share code, notes, and snippets.

@jvanderen1
Created December 1, 2019 21:10
Show Gist options
  • Save jvanderen1/ae502ec7e255625e41cce55a72621f67 to your computer and use it in GitHub Desktop.
Save jvanderen1/ae502ec7e255625e41cce55a72621f67 to your computer and use it in GitHub Desktop.
describe('Lifecycle', () => {
let instance;
let newComponent;
const updateComponent = (props) => (
<TestPage {...{ ...defaultProps, ...props }} />
);
beforeEach(() => {
component = getComponent();
instance = component.root.instance;
instance.handleSetTableValues = jest.fn();
});
afterEach(() => {
jest.clearAllMocks();
});
it('updates table values when `numCols` changes', () => {
newComponent = updateComponent({ numCols: 0 });
component.update(newComponent);
expect(instance.handleSetTableValues).toHaveBeenCalled();
});
it('updates table values when `numRows` changes', () => {
newComponent = updateComponent({ numRows: 0 });
component.update(newComponent);
expect(instance.handleSetTableValues).toHaveBeenCalled();
});
it('does not update table values when neither `numCols` or `numRows` changes', () => {
newComponent = updateComponent();
component.update(newComponent);
expect(instance.handleSetTableValues).not.toHaveBeenCalled();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment