@@ -4,6 +4,8 @@ import { BrowserRouter as Router } from 'react-router-dom';
4
4
import renderer from 'react-test-renderer' ;
5
5
import { ThemeWrapped } from '../../test-utils/theme-wrapped' ;
6
6
import { GlobalNavigation , GlobalNavigationItem } from './global-navigation' ;
7
+ import { ButtonProps } from '../buttons/icon-button' ;
8
+ import { findByTestId } from '../../test-utils/enzyme-selectors' ;
7
9
8
10
function setup ( children : ReactElement ) : ReactElement {
9
11
return (
@@ -16,44 +18,51 @@ function setup(children: ReactElement): ReactElement {
16
18
const items : GlobalNavigationItem [ ] = [
17
19
{
18
20
iconName : 'home' ,
19
- name : 'test ' ,
21
+ name : 'home ' ,
20
22
href : '/test1' ,
21
23
} ,
22
24
{
23
25
iconName : 'edit' ,
24
- name : 'test ' ,
26
+ name : 'edit ' ,
25
27
href : '/test2' ,
26
28
} ,
27
29
{
28
30
iconName : 'mapPin' ,
29
- name : 'test ' ,
31
+ name : 'map ' ,
30
32
href : '/test3' ,
31
33
} ,
32
34
{
33
35
iconName : 'mail' ,
34
- name : 'test ' ,
36
+ name : 'mail ' ,
35
37
href : '/test4' ,
36
38
} ,
37
39
{
38
40
iconName : 'phone' ,
39
- name : 'test ' ,
41
+ name : 'phone ' ,
40
42
href : '/test5' ,
41
43
} ,
42
44
] ;
43
45
44
46
const footerItems : GlobalNavigationItem [ ] = [
45
47
{
46
48
iconName : 'info' ,
47
- name : 'test ' ,
49
+ name : 'info ' ,
48
50
href : '/test6' ,
49
51
} ,
50
52
{
51
53
iconName : 'helpCircle' ,
52
- name : 'test ' ,
54
+ name : 'help ' ,
53
55
href : '/test7' ,
54
56
} ,
55
57
] ;
56
58
59
+ const coreActionButton : ButtonProps = {
60
+ buttonType : 'primary' ,
61
+ iconName : 'plusSign' ,
62
+ label : 'add' ,
63
+ type : 'button' ,
64
+ } ;
65
+
57
66
describe ( 'Global Navigation' , ( ) => {
58
67
test ( 'Has showMore icon' , ( ) => {
59
68
const wrapper = mount (
@@ -64,14 +73,26 @@ describe('Global Navigation', () => {
64
73
) ,
65
74
) ;
66
75
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 ) ;
68
89
} ) ;
69
90
70
91
test ( 'Matches snapshot' , ( ) => {
71
92
const tree = renderer . create (
72
93
setup (
73
94
< div style = { { height : '600px' } } >
74
- < GlobalNavigation mainItems = { items } footerItems = { footerItems } />
95
+ < GlobalNavigation mainItems = { items } footerItems = { footerItems } coreActionButton = { coreActionButton } />
75
96
</ div > ,
76
97
) ,
77
98
) ;
0 commit comments