2018-12-12 23:53:36 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { configure, mount } from 'enzyme';
|
|
|
|
import toJson from 'enzyme-to-json';
|
|
|
|
import StackTraceTab from '../src/StackTraceTab';
|
|
|
|
|
2019-01-02 02:07:16 +03:00
|
|
|
import Adapter from 'enzyme-adapter-react-16';
|
2018-12-12 23:53:36 +03:00
|
|
|
configure({ adapter: new Adapter() });
|
|
|
|
|
|
|
|
function genAsyncSnapshot(component, done) {
|
|
|
|
setTimeout(() => {
|
|
|
|
component.update();
|
|
|
|
expect(toJson(component)).toMatchSnapshot();
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const actions = {
|
|
|
|
0: { type: 'PERFORM_ACTION', action: { type: '@@INIT' } },
|
|
|
|
1: { type: 'PERFORM_ACTION', action: { type: 'INCREMENT_COUNTER' } },
|
|
|
|
2: {
|
2019-01-10 21:51:14 +03:00
|
|
|
type: 'PERFORM_ACTION',
|
|
|
|
action: { type: 'INCREMENT_COUNTER' },
|
|
|
|
stack:
|
|
|
|
'Error\n at fn1 (app.js:72:24)\n at fn2 (app.js:84:31)\n ' +
|
2019-01-10 20:23:33 +03:00
|
|
|
'at fn3 (chrome-extension://lmhkpmbekcpmknklioeibfkpmmfibljd/js/page.bundle.js:1269:80)'
|
2018-12-12 23:53:36 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('StackTraceTab component', () => {
|
2019-01-10 21:51:14 +03:00
|
|
|
it('should render with no props', done => {
|
2018-12-12 23:53:36 +03:00
|
|
|
const component = mount(<StackTraceTab />);
|
|
|
|
genAsyncSnapshot(component, done);
|
|
|
|
});
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
it('should render with props, but without stack', done => {
|
2018-12-12 23:53:36 +03:00
|
|
|
const component = mount(
|
2019-01-10 21:51:14 +03:00
|
|
|
<StackTraceTab actions={actions} action={actions[0].action} />
|
2018-12-12 23:53:36 +03:00
|
|
|
);
|
|
|
|
genAsyncSnapshot(component, done);
|
|
|
|
});
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
it('should render the link to docs', done => {
|
2018-12-18 20:26:17 +03:00
|
|
|
const component = mount(
|
2019-01-10 21:51:14 +03:00
|
|
|
<StackTraceTab actions={actions} action={actions[1].action} />
|
2018-12-18 20:26:17 +03:00
|
|
|
);
|
|
|
|
genAsyncSnapshot(component, done);
|
|
|
|
});
|
|
|
|
|
2019-01-10 21:51:14 +03:00
|
|
|
it('should render with trace stack', done => {
|
2018-12-12 23:53:36 +03:00
|
|
|
const component = mount(
|
2019-01-10 21:51:14 +03:00
|
|
|
<StackTraceTab actions={actions} action={actions[2].action} />
|
2018-12-12 23:53:36 +03:00
|
|
|
);
|
|
|
|
genAsyncSnapshot(component, done);
|
|
|
|
});
|
|
|
|
});
|