mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2024-11-24 18:43:54 +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.7 KiB
JavaScript
54 lines
1.7 KiB
JavaScript
import expect from 'expect';
|
|
import React from 'react';
|
|
import TestUtils from 'react-addons-test-utils';
|
|
import { Provider } from 'react-redux';
|
|
import App from '../../containers/App';
|
|
import configureStore from '../../store/configureStore';
|
|
|
|
function setup(initialState) {
|
|
const store = configureStore(initialState);
|
|
const app = TestUtils.renderIntoDocument(
|
|
<Provider store={store}>
|
|
<App />
|
|
</Provider>,
|
|
);
|
|
return {
|
|
app: app,
|
|
buttons: TestUtils.scryRenderedDOMComponentsWithTag(app, 'button'),
|
|
p: TestUtils.findRenderedDOMComponentWithTag(app, 'p'),
|
|
};
|
|
}
|
|
|
|
describe('containers', () => {
|
|
describe('App', () => {
|
|
it('should display initial count', () => {
|
|
const { p } = setup();
|
|
expect(p.textContent).toMatch(/^Clicked: 0 times/);
|
|
});
|
|
|
|
it('should display updated count after increment button click', () => {
|
|
const { buttons, p } = setup();
|
|
TestUtils.Simulate.click(buttons[0]);
|
|
expect(p.textContent).toMatch(/^Clicked: 1 times/);
|
|
});
|
|
|
|
it('should display updated count after decrement button click', () => {
|
|
const { buttons, p } = setup();
|
|
TestUtils.Simulate.click(buttons[1]);
|
|
expect(p.textContent).toMatch(/^Clicked: -1 times/);
|
|
});
|
|
|
|
it('shouldnt change if even and if odd button clicked', () => {
|
|
const { buttons, p } = setup();
|
|
TestUtils.Simulate.click(buttons[2]);
|
|
expect(p.textContent).toMatch(/^Clicked: 0 times/);
|
|
});
|
|
|
|
it('should change if odd and if odd button clicked', () => {
|
|
const { buttons, p } = setup({ counter: 1 });
|
|
TestUtils.Simulate.click(buttons[2]);
|
|
expect(p.textContent).toMatch(/^Clicked: 2 times/);
|
|
});
|
|
});
|
|
});
|