don’t render leftpanel stories tree if stories are empty

This commit is contained in:
Daniel Sneijers 2017-08-15 11:49:51 +02:00
parent db69a1098d
commit 7addf9f69d
2 changed files with 10 additions and 1 deletions

View File

@ -46,7 +46,9 @@ class LeftPanel extends Component {
onChange={text => onStoryFilter(text)}
/>
<div style={scrollStyle}>
{storiesHierarchy ? <Stories {...pick(this.props, storyProps)} /> : null}
{storiesHierarchy && storiesHierarchy.map.size
? <Stories {...pick(this.props, storyProps)} />
: null}
</div>
</div>
);

View File

@ -44,6 +44,13 @@ describe('manager.ui.components.left_panel.index', () => {
});
});
test('should not render stories if storiesHierarchy exists but is empty', () => {
const storiesHierarchy = createHierarchy([]);
const wrap = shallow(<LeftPanel storiesHierarchy={storiesHierarchy} />);
expect(wrap.find(Stories).exists()).toBe(false);
});
describe('onStoryFilter prop', () => {
test('should set filter as an empty text on TextFilter.onClear', () => {
const onStoryFilter = jest.fn();