mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-27 12:03:56 +03:00
922985f9ea
* chore(deps): update dependency prettier to v3 * Format --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Nathan Bierema <nbierema@gmail.com>
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import expect from 'expect';
|
|
import React from 'react';
|
|
import TestUtils from 'react-addons-test-utils';
|
|
import Counter from '../../components/Counter';
|
|
|
|
function setup() {
|
|
const actions = {
|
|
increment: expect.createSpy(),
|
|
incrementIfOdd: expect.createSpy(),
|
|
incrementAsync: expect.createSpy(),
|
|
decrement: expect.createSpy(),
|
|
};
|
|
const component = TestUtils.renderIntoDocument(
|
|
<Counter counter={1} {...actions} />,
|
|
);
|
|
return {
|
|
component: component,
|
|
actions: actions,
|
|
buttons: TestUtils.scryRenderedDOMComponentsWithTag(component, 'button'),
|
|
p: TestUtils.findRenderedDOMComponentWithTag(component, 'p'),
|
|
};
|
|
}
|
|
|
|
describe('Counter component', () => {
|
|
it('should display count', () => {
|
|
const { p } = setup();
|
|
expect(p.textContent).toMatch(/^Clicked: 1 times/);
|
|
});
|
|
|
|
it('first button should call increment', () => {
|
|
const { buttons, actions } = setup();
|
|
TestUtils.Simulate.click(buttons[0]);
|
|
expect(actions.increment).toHaveBeenCalled();
|
|
});
|
|
|
|
it('second button should call decrement', () => {
|
|
const { buttons, actions } = setup();
|
|
TestUtils.Simulate.click(buttons[1]);
|
|
expect(actions.decrement).toHaveBeenCalled();
|
|
});
|
|
|
|
it('third button should call incrementIfOdd', () => {
|
|
const { buttons, actions } = setup();
|
|
TestUtils.Simulate.click(buttons[2]);
|
|
expect(actions.incrementIfOdd).toHaveBeenCalled();
|
|
});
|
|
|
|
it('fourth button should call incrementAsync', () => {
|
|
const { buttons, actions } = setup();
|
|
TestUtils.Simulate.click(buttons[3]);
|
|
expect(actions.incrementAsync).toHaveBeenCalled();
|
|
});
|
|
});
|