Skip to content

Commit d1da84a

Browse files
author
Jeremi LC
committed
feat: add feature to global navigation
1 parent 38bf874 commit d1da84a

File tree

5 files changed

+522
-329
lines changed

5 files changed

+522
-329
lines changed

packages/react/src/components/buttons/icon-button.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type ButtonType = 'primary' | 'secondary' | 'tertiary' | 'destructive';
88

99
type Type = 'submit' | 'button' | 'reset';
1010

11-
interface ButtonProps {
11+
export interface ButtonProps {
1212
/**
1313
* Visual style
1414
* @default primary

packages/react/src/components/global-navigation/global-navigation.test.tsx

+30-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { BrowserRouter as Router } from 'react-router-dom';
44
import renderer from 'react-test-renderer';
55
import { ThemeWrapped } from '../../test-utils/theme-wrapped';
66
import { GlobalNavigation, GlobalNavigationItem } from './global-navigation';
7+
import { ButtonProps } from '../buttons/icon-button';
8+
import { findByTestId } from '../../test-utils/enzyme-selectors';
79

810
function setup(children: ReactElement): ReactElement {
911
return (
@@ -16,44 +18,51 @@ function setup(children: ReactElement): ReactElement {
1618
const items: GlobalNavigationItem[] = [
1719
{
1820
iconName: 'home',
19-
name: 'test',
21+
name: 'home',
2022
href: '/test1',
2123
},
2224
{
2325
iconName: 'edit',
24-
name: 'test',
26+
name: 'edit',
2527
href: '/test2',
2628
},
2729
{
2830
iconName: 'mapPin',
29-
name: 'test',
31+
name: 'map',
3032
href: '/test3',
3133
},
3234
{
3335
iconName: 'mail',
34-
name: 'test',
36+
name: 'mail',
3537
href: '/test4',
3638
},
3739
{
3840
iconName: 'phone',
39-
name: 'test',
41+
name: 'phone',
4042
href: '/test5',
4143
},
4244
];
4345

4446
const footerItems: GlobalNavigationItem[] = [
4547
{
4648
iconName: 'info',
47-
name: 'test',
49+
name: 'info',
4850
href: '/test6',
4951
},
5052
{
5153
iconName: 'helpCircle',
52-
name: 'test',
54+
name: 'help',
5355
href: '/test7',
5456
},
5557
];
5658

59+
const coreActionButton: ButtonProps = {
60+
buttonType: 'primary',
61+
iconName: 'plusSign',
62+
label: 'add',
63+
type: 'button',
64+
};
65+
5766
describe('Global Navigation', () => {
5867
test('Has showMore icon', () => {
5968
const wrapper = mount(
@@ -64,14 +73,26 @@ describe('Global Navigation', () => {
6473
),
6574
);
6675

67-
expect(wrapper.find('[data-testid="showMoreIcon"]').at(0).length).toBe(1);
76+
expect(findByTestId(wrapper, 'showMoreIcon').exists()).toBe(true);
77+
});
78+
79+
test('Has CoreActionButton when needed', () => {
80+
const wrapper = mount(
81+
setup(
82+
<div style={{ height: '600px' }}>
83+
<GlobalNavigation mainItems={items} footerItems={footerItems} coreActionButton={coreActionButton} />
84+
</div>,
85+
),
86+
);
87+
88+
expect(findByTestId(wrapper, 'coreActionButton').exists()).toBe(true);
6889
});
6990

7091
test('Matches snapshot', () => {
7192
const tree = renderer.create(
7293
setup(
7394
<div style={{ height: '600px' }}>
74-
<GlobalNavigation mainItems={items} footerItems={footerItems} />
95+
<GlobalNavigation mainItems={items} footerItems={footerItems} coreActionButton={coreActionButton} />
7596
</div>,
7697
),
7798
);

0 commit comments

Comments
 (0)