feat(dashboard): direct link to single chart/tab/header in dashboard (#6964)

* direct display for pre-selected tab

* update parents

* add AnchorLink component

* add unit tests
This commit is contained in:
Grace Guo
2019-04-09 15:42:46 -07:00
committed by GitHub
parent 139f299ab3
commit c50e6bc981
33 changed files with 813 additions and 26 deletions

View File

@@ -18,7 +18,7 @@
*/
import { Provider } from 'react-redux';
import React from 'react';
import { mount } from 'enzyme';
import { mount, shallow } from 'enzyme';
import sinon from 'sinon';
import { Tabs as BootstrapTabs, Tab as BootstrapTab } from 'react-bootstrap';
@@ -154,4 +154,20 @@ describe('Tabs', () => {
expect(deleteComponent.callCount).toBe(1);
});
it('should direct display direct-link tab', () => {
let wrapper = shallow(<Tabs {...props} />);
// default show first tab child
expect(wrapper.state('tabIndex')).toBe(0);
// display child in directPathToChild list
const directPathToChild = dashboardLayoutWithTabs.present.ROW_ID2.parents.slice();
const directLinkProps = {
...props,
directPathToChild,
};
wrapper = shallow(<Tabs {...directLinkProps} />);
expect(wrapper.state('tabIndex')).toBe(1);
});
});