chore: refactor submenu's right nav to accept list of buttons (#11102)

* submenu right-nav button refactor

* undo changes

* fix lint

* fix test

* update pr with suggested changes and test

* fix lint

* use enum to define btn style props

* add suggestions

* update savedquery buttons
This commit is contained in:
Phillip Kelley-Dotson
2020-10-01 15:05:49 -07:00
committed by GitHub
parent 2a906bc9d1
commit 07716ffd76
7 changed files with 106 additions and 65 deletions

View File

@@ -85,4 +85,24 @@ describe('SubMenu', () => {
expect(routerWrapper.find(Link)).toHaveLength(2);
expect(routerWrapper.find(MenuItem)).toHaveLength(1);
});
it('renders buttons in the right nav of the submenu', () => {
const mockFunc = jest.fn();
const buttons = [
{
name: 'test_button',
onClick: mockFunc,
buttonStyle: 'primary',
},
{
name: 'danger_button',
buttonStyle: 'danger',
},
];
const overrideProps = { buttons };
const newWrapper = getWrapper(overrideProps);
expect(newWrapper.find('.navbar-right').children()).toHaveLength(2);
newWrapper.find('[buttonStyle="primary"]').simulate('click');
expect(mockFunc).toHaveBeenCalled();
});
});