Skip to content

Commit

Permalink
Add a test for the button state
Browse files Browse the repository at this point in the history
  • Loading branch information
julienw committed Jul 13, 2018
1 parent 93e2399 commit 5163a4b
Show file tree
Hide file tree
Showing 2 changed files with 242 additions and 9 deletions.
17 changes: 15 additions & 2 deletions src/test/components/Details.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import * as React from 'react';
import { shallowWithStore } from '../fixtures/enzyme';

import Details from '../../components/app/Details';
import { changeSelectedTab } from '../../actions/app';
import { changeSelectedTab, changeSidebarOpenState } from '../../actions/app';
import { storeWithProfile } from '../fixtures/stores';
import { getProfileFromTextSamples } from '../fixtures/profiles/make-profile';

import { tabSlugs } from '../../app-logic/tabs-handling';
import type { TabSlug } from '../../app-logic/tabs-handling';

describe('app/DetailsContainer', function() {
describe('app/Details', function() {
const { profile } = getProfileFromTextSamples(`
A A A
B B B
Expand All @@ -39,4 +39,17 @@ describe('app/DetailsContainer', function() {
expect(view.dive()).toMatchSnapshot();
});
});

it('show the correct state for the sidebar open button', function() {
const store = storeWithProfile(profile);
const view = shallowWithStore(<Details />, store);
expect(view.dive()).toMatchSnapshot();
store.dispatch(changeSidebarOpenState('calltree', true));
expect(view.dive()).toMatchSnapshot();
store.dispatch(changeSelectedTab('flame-graph'));
expect(view.dive()).toMatchSnapshot();
store.dispatch(changeSidebarOpenState('calltree', false));
store.dispatch(changeSelectedTab('calltree'));
expect(view.dive()).toMatchSnapshot();
});
});
234 changes: 227 additions & 7 deletions src/test/components/__snapshots__/Details.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`app/DetailsContainer renders an initial view with the right panel 1`] = `
exports[`app/Details renders an initial view with the right panel 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -55,7 +55,7 @@ exports[`app/DetailsContainer renders an initial view with the right panel 1`] =
</div>
`;

exports[`app/DetailsContainer renders an initial view with the right panel for tab calltree 1`] = `
exports[`app/Details renders an initial view with the right panel for tab calltree 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -110,7 +110,7 @@ exports[`app/DetailsContainer renders an initial view with the right panel for t
</div>
`;

exports[`app/DetailsContainer renders an initial view with the right panel for tab flame-graph 1`] = `
exports[`app/Details renders an initial view with the right panel for tab flame-graph 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -165,7 +165,7 @@ exports[`app/DetailsContainer renders an initial view with the right panel for t
</div>
`;

exports[`app/DetailsContainer renders an initial view with the right panel for tab marker-chart 1`] = `
exports[`app/Details renders an initial view with the right panel for tab marker-chart 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -220,7 +220,7 @@ exports[`app/DetailsContainer renders an initial view with the right panel for t
</div>
`;

exports[`app/DetailsContainer renders an initial view with the right panel for tab marker-table 1`] = `
exports[`app/Details renders an initial view with the right panel for tab marker-table 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -275,7 +275,7 @@ exports[`app/DetailsContainer renders an initial view with the right panel for t
</div>
`;

exports[`app/DetailsContainer renders an initial view with the right panel for tab network-chart 1`] = `
exports[`app/Details renders an initial view with the right panel for tab network-chart 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -330,7 +330,7 @@ exports[`app/DetailsContainer renders an initial view with the right panel for t
</div>
`;

exports[`app/DetailsContainer renders an initial view with the right panel for tab stack-chart 1`] = `
exports[`app/Details renders an initial view with the right panel for tab stack-chart 1`] = `
<div
className="Details"
>
Expand Down Expand Up @@ -384,3 +384,223 @@ exports[`app/DetailsContainer renders an initial view with the right panel for t
<Connect(ProfileThreadHeaderContextMenu) />
</div>
`;

exports[`app/Details show the correct state for the sidebar open button 1`] = `
<div
className="Details"
>
<TabBar
extraElements={false}
onChangeTabOrder={[Function]}
onSelectTab={[Function]}
selectedTabName="calltree"
tabOrder={
Array [
0,
1,
2,
3,
4,
5,
]
}
tabs={
Array [
Object {
"name": "calltree",
"title": "Call Tree",
},
Object {
"name": "flame-graph",
"title": "Flame Graph",
},
Object {
"name": "stack-chart",
"title": "Stack Chart",
},
Object {
"name": "marker-chart",
"title": "Marker Chart",
},
Object {
"name": "marker-table",
"title": "Marker Table",
},
Object {
"name": "network-chart",
"title": "Network",
},
]
}
/>
<ProfileCallTreeView />
<Connect(CallNodeContextMenu) />
<Connect(MarkersContextMenu) />
<Connect(ProfileThreadHeaderContextMenu) />
</div>
`;

exports[`app/Details show the correct state for the sidebar open button 2`] = `
<div
className="Details"
>
<TabBar
extraElements={false}
onChangeTabOrder={[Function]}
onSelectTab={[Function]}
selectedTabName="calltree"
tabOrder={
Array [
0,
1,
2,
3,
4,
5,
]
}
tabs={
Array [
Object {
"name": "calltree",
"title": "Call Tree",
},
Object {
"name": "flame-graph",
"title": "Flame Graph",
},
Object {
"name": "stack-chart",
"title": "Stack Chart",
},
Object {
"name": "marker-chart",
"title": "Marker Chart",
},
Object {
"name": "marker-table",
"title": "Marker Table",
},
Object {
"name": "network-chart",
"title": "Network",
},
]
}
/>
<ProfileCallTreeView />
<Connect(CallNodeContextMenu) />
<Connect(MarkersContextMenu) />
<Connect(ProfileThreadHeaderContextMenu) />
</div>
`;

exports[`app/Details show the correct state for the sidebar open button 3`] = `
<div
className="Details"
>
<TabBar
extraElements={false}
onChangeTabOrder={[Function]}
onSelectTab={[Function]}
selectedTabName="calltree"
tabOrder={
Array [
0,
1,
2,
3,
4,
5,
]
}
tabs={
Array [
Object {
"name": "calltree",
"title": "Call Tree",
},
Object {
"name": "flame-graph",
"title": "Flame Graph",
},
Object {
"name": "stack-chart",
"title": "Stack Chart",
},
Object {
"name": "marker-chart",
"title": "Marker Chart",
},
Object {
"name": "marker-table",
"title": "Marker Table",
},
Object {
"name": "network-chart",
"title": "Network",
},
]
}
/>
<ProfileCallTreeView />
<Connect(CallNodeContextMenu) />
<Connect(MarkersContextMenu) />
<Connect(ProfileThreadHeaderContextMenu) />
</div>
`;

exports[`app/Details show the correct state for the sidebar open button 4`] = `
<div
className="Details"
>
<TabBar
extraElements={false}
onChangeTabOrder={[Function]}
onSelectTab={[Function]}
selectedTabName="calltree"
tabOrder={
Array [
0,
1,
2,
3,
4,
5,
]
}
tabs={
Array [
Object {
"name": "calltree",
"title": "Call Tree",
},
Object {
"name": "flame-graph",
"title": "Flame Graph",
},
Object {
"name": "stack-chart",
"title": "Stack Chart",
},
Object {
"name": "marker-chart",
"title": "Marker Chart",
},
Object {
"name": "marker-table",
"title": "Marker Table",
},
Object {
"name": "network-chart",
"title": "Network",
},
]
}
/>
<ProfileCallTreeView />
<Connect(CallNodeContextMenu) />
<Connect(MarkersContextMenu) />
<Connect(ProfileThreadHeaderContextMenu) />
</div>
`;

0 comments on commit 5163a4b

Please sign in to comment.