Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the react-redux version #2535

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 52 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/jaeger-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
"react-icons": "^5.0.1",
"react-is": "^18.2.0",
"react-json-view-lite": "2.0.1",
"react-redux": "^8.1.2",
"react-redux": "^9.2.0",
"react-router-dom": "5.3.4",
"react-router-dom-v5-compat": "^6.24.0",
"react-vis": "1.11.12",
"react-vis-force": "^0.3.1",
"react-window": "^1.8.10",
"redux": "^4.2.1",
"redux": "^5.0.1",
"redux-actions": "2.6.5",
"redux-first-history": "^5.2.0",
"redux-form": "^8.3.10",
Expand Down
68 changes: 48 additions & 20 deletions packages/jaeger-ui/src/components/TraceDiff/TraceDiff.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ import * as TraceDiffUrl from './url';
import * as jaegerApiActions from '../../actions/jaeger-api';
import { fetchedState, TOP_NAV_HEIGHT } from '../../constants';

jest.mock('../../actions/jaeger-api', () => ({
fetchMultipleTraces: jest.fn(),
}));

jest.mock('./duck', () => ({
actions: {
forceState: jest.fn(),
},
}));

describe('TraceDiff', () => {
const defaultA = 'trace-id-a';
const defaultB = 'trace-id-b';
Expand Down Expand Up @@ -341,30 +351,48 @@ describe('TraceDiff', () => {
});

describe('mapDispatchToProps', () => {
let bindActionCreatorsSpy;

beforeAll(() => {
bindActionCreatorsSpy = jest.spyOn(redux, 'bindActionCreators').mockImplementation(actions => {
if (actions === jaegerApiActions) {
return { fetchMultipleTraces: fetchMultipleTracesMock };
}
if (actions === diffActions) {
return { forceState: forceStateMock };
}
return {};
});
const dispatchMock = jest.fn();
let boundActions;

beforeEach(() => {
dispatchMock.mockClear();
boundActions = mapDispatchToProps(dispatchMock);
});

it('correctly binds fetchMultipleTraces to dispatch', () => {
const testArg = ['trace1', 'trace2'];
boundActions.fetchMultipleTraces(testArg);
expect(dispatchMock).toHaveBeenCalledWith(fetchMultipleTracesMock(testArg));
});

it('correctly binds forceState to dispatch', () => {
const testState = { a: 'a', b: 'b', cohort: ['a', 'b'] };
boundActions.forceState(testState);
expect(dispatchMock).toHaveBeenCalledWith(forceStateMock(testState));
});
});

describe('render', () => {
it('renders as expected', () => {
expect(wrapper).toMatchSnapshot();
});

afterAll(() => {
bindActionCreatorsSpy.mockRestore();
it('handles a and b not in props.tracesData', () => {
const tracesData = new Map(defaultProps.tracesData);
tracesData.delete(defaultA);
tracesData.delete(defaultB);
wrapper.setProps({ tracesData });
expect(wrapper.find(TraceDiffHeader).props()).toEqual(
expect.objectContaining({
a: { id: defaultA },
b: { id: defaultB },
})
);
});

it('correctly binds actions to dispatch', () => {
const dispatchMock = () => {};
const result = mapDispatchToProps(dispatchMock);
expect(result.fetchMultipleTraces).toBe(fetchMultipleTracesMock);
expect(result.forceState).toBe(forceStateMock);
expect(bindActionCreatorsSpy.mock.calls[0][1]).toBe(dispatchMock);
it('handles absent a and b', () => {
wrapper.setProps({ a: null, b: null });
expect(wrapper.find(TraceDiffHeader).props()).toEqual(expect.objectContaining({ a: null, b: null }));
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,77 @@ exports[`TraceDiff render renders as expected 1`] = `
</div>
</Fragment>
`;

exports[`TraceDiff render renders as expected 2`] = `
<Fragment>
<div
key="header"
>
<TraceDiffHeader
a={
Object {
"id": "trace-id-a",
"state": "FETCH_DONE",
}
}
b={
Object {
"id": "trace-id-b",
"state": "FETCH_DONE",
}
}
cohort={
Array [
Object {
"id": "trace-id-a",
"state": "FETCH_DONE",
},
Object {
"id": "trace-id-b",
"state": "FETCH_DONE",
},
Object {
"id": "trace-id-cohort-0",
"state": "FETCH_DONE",
},
Object {
"id": "trace-id-cohort-1",
"state": "FETCH_DONE",
},
Object {
"id": "trace-id-cohort-2",
"state": "FETCH_DONE",
},
]
}
diffSetA={[Function]}
diffSetB={[Function]}
key="header"
/>
</div>
<div
className="TraceDiff--graphWrapper"
key="graph"
style={
Object {
"top": 46,
}
}
>
<Connect(UnconnectedTraceDiffGraph)
a={
Object {
"id": "trace-id-a",
"state": "FETCH_DONE",
}
}
b={
Object {
"id": "trace-id-b",
"state": "FETCH_DONE",
}
}
/>
</div>
</Fragment>
`;
2 changes: 1 addition & 1 deletion packages/jaeger-ui/src/types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type LocationState = {

export type ReduxState = {
archive: TracesArchive;
type: Action;
type: string;
config: Config;
ddg: TDdgState;
dependencies: {
Expand Down
Loading