redux-devtools/packages/redux-devtools-core/test/app.spec.js

70 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-01-03 17:14:25 +03:00
import React from 'react';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { mount } from 'enzyme';
// import { mountToJson } from 'enzyme-to-json';
import App from '../src/app/containers/App';
import api from '../src/app/middlewares/api';
import exportState from '../src/app/middlewares/exportState';
import rootReducer from '../src/app/reducers';
import { DATA_TYPE_KEY } from '../src/app/constants/dataTypes';
import stringifyJSON from '../src/app/utils/stringifyJSON';
2019-01-03 17:14:25 +03:00
let wrapper;
const store = createStore(rootReducer, applyMiddleware(exportState, api));
describe('App container', () => {
beforeAll(() => {
wrapper = mount(
<Provider store={store}>
<App />
</Provider>
);
});
2019-01-10 21:51:14 +03:00
/*
2019-01-03 17:14:25 +03:00
it('should render the App', () => {
expect(mountToJson(wrapper)).toMatchSnapshot();
});
*/
2019-01-10 21:51:14 +03:00
it("should render inspector monitor's wrapper", () => {
2019-01-03 17:14:25 +03:00
expect(wrapper.find('DevtoolsInspector').html()).toBeDefined();
});
it('should contain an empty action list', () => {
expect(
2019-01-10 21:51:14 +03:00
wrapper
.find('ActionList')
.findWhere((n) => {
2019-01-10 21:51:14 +03:00
const { className } = n.props();
return className && className.startsWith('actionListRows-');
})
.html()
).toMatch(/<div class="actionListRows-\d-\d-\d+"><\/div>/);
2019-01-03 17:14:25 +03:00
});
});
describe('stringifyJSON', () => {
it('should not mutate the source object', () => {
const src = {
isTest: true,
[DATA_TYPE_KEY]: 'Test',
};
const result = {
data: {
isTest: true,
},
__serializedType__: 'Test',
};
expect(stringifyJSON(src, true)).toEqual(JSON.stringify(result));
expect(src).toEqual({
isTest: true,
[DATA_TYPE_KEY]: 'Test',
});
});
});