1
1
import React from 'react'
2
2
3
- import Menu from 'src/collections/Menu/Menu'
4
3
import MenuItem from 'src/collections/Menu/MenuItem'
5
4
import * as common from 'test/specs/commonTests'
6
- import { sandbox } from 'test/utils/sandbox '
5
+ import { sandbox } from 'test/utils'
7
6
8
7
describe ( 'MenuItem' , ( ) => {
9
8
common . isConformant ( MenuItem )
@@ -18,13 +17,6 @@ describe('MenuItem', () => {
18
17
. should . have . tagName ( 'div' )
19
18
} )
20
19
21
- describe ( 'active' , ( ) => {
22
- it ( 'is not by default' , ( ) => {
23
- shallow ( < MenuItem name = 'item' /> )
24
- . should . not . have . className ( 'active' )
25
- } )
26
- } )
27
-
28
20
describe ( 'name' , ( ) => {
29
21
it ( 'uses the name prop as text' , ( ) => {
30
22
shallow ( < MenuItem name = 'This is an item' /> )
@@ -33,28 +25,21 @@ describe('MenuItem', () => {
33
25
} )
34
26
35
27
describe ( 'onClick' , ( ) => {
36
- it ( 'is called when clicked' , ( ) => {
37
- const handleClick = sandbox . spy ( )
28
+ it ( 'is called with (e, { name, index }) when clicked' , ( ) => {
29
+ const spy = sandbox . spy ( )
30
+ const event = { target : null }
31
+ const props = { name : 'home' , index : 0 }
38
32
39
- const wrapper = shallow ( < MenuItem onClick = { handleClick } /> )
40
- wrapper . simulate ( 'click' )
33
+ shallow ( < MenuItem onClick = { spy } { ... props } /> )
34
+ . simulate ( 'click' , event )
41
35
42
- handleClick . should . have . been . called ( )
36
+ spy . should . have . been . calledOnce ( )
37
+ spy . should . have . been . calledWithMatch ( event , props )
43
38
} )
39
+
44
40
it ( 'renders an `a` tag' , ( ) => {
45
41
shallow ( < MenuItem onClick = { ( ) => null } /> )
46
42
. should . have . tagName ( 'a' )
47
43
} )
48
- it ( 'is called when the item is clicked' , ( ) => {
49
- const props = {
50
- onClick : sandbox . spy ( ) ,
51
- }
52
-
53
- // mount to get click event to propagate on click
54
- mount ( < MenuItem { ...props } /> )
55
- . simulate ( 'click' )
56
-
57
- props . onClick . should . have . been . calledOnce ( )
58
- } )
59
44
} )
60
45
} )
0 commit comments