@@ -10,41 +10,51 @@ describe('unit testing for Action.jsx', () => {
10
10
const props = {
11
11
selected : true ,
12
12
handleChangeSnapshot : jest . fn ( ) ,
13
- handleSendSnapshot : jest . fn ( ) ,
13
+ handleJumpSnapshot : jest . fn ( ) ,
14
14
index : 1 ,
15
15
} ;
16
16
beforeEach ( ( ) => {
17
17
wrapper = shallow ( < Action { ...props } /> ) ;
18
18
} ) ;
19
19
20
- describe ( '<Action> component ' , ( ) => {
21
- it ( "<Action> should have a className 'action-component selected' if props.selected is true", ( ) => {
20
+ describe ( 'Component ' , ( ) => {
21
+ test ( " should have a className 'action-component selected' if props.selected is true", ( ) => {
22
22
wrapper . setProps ( { selected : true } ) ;
23
23
expect ( wrapper . hasClass ( 'action-component selected' ) ) . toEqual ( true ) ;
24
24
} ) ;
25
25
26
- it ( "<Action> shouldn't have a className 'action-component selected' if props.selected is false", ( ) => {
26
+ test ( " shouldn't have a className 'action-component selected' if props.selected is false", ( ) => {
27
27
wrapper . setProps ( { selected : false } ) ;
28
28
expect ( wrapper . hasClass ( 'action-component selected' ) ) . toEqual ( false ) ;
29
29
} ) ;
30
30
31
- it ( '<Action> should have a text that is equal to props.index', ( ) => {
31
+ test ( ' should have a text that is equal to props.index', ( ) => {
32
32
expect ( wrapper . find ( '.action-component-text' ) . text ( ) ) . toEqual ( props . index . toString ( ) ) ;
33
33
} ) ;
34
+
35
+ test ( 'should invoke changeSnapshot method when clicked' , ( ) => {
36
+ wrapper . find ( '.action-component' ) . simulate ( 'click' ) ;
37
+ expect ( props . handleChangeSnapshot ) . toHaveBeenCalled ( ) ;
38
+ } ) ;
34
39
} ) ;
35
40
36
- describe ( 'jump button' , ( ) => {
37
- it ( 'Should render a jump button' , ( ) => {
38
- expect ( wrapper . type ( ) ) . toEqual ( 'div' ) ;
39
- expect ( wrapper . find ( 'button' ) ) . toHaveLength ( 1 ) ;
41
+ describe ( 'Jump Button' , ( ) => {
42
+ test ( "should render a div with a className 'jump-button' inside action-component" , ( ) => {
43
+ expect (
44
+ wrapper
45
+ . find ( '.action-component' )
46
+ . children ( )
47
+ . find ( '.jump-button' ) ,
48
+ ) . toHaveLength ( 1 ) ;
40
49
} ) ;
41
50
42
- it ( 'Should invoke the sendSnapshot method when the jump button is clicked', ( ) => {
51
+ test ( 'should invoke jumpSnapshot method when clicked', ( ) => {
43
52
wrapper
44
- . find ( 'button' )
45
- . at ( 0 )
53
+ . find ( '.action-component' )
54
+ . children ( )
55
+ . find ( '.jump-button' )
46
56
. simulate ( 'click' ) ;
47
- expect ( props . handleSendSnapshot ) . toHaveBeenCalled ( ) ;
57
+ expect ( props . handleJumpSnapshot ) . toHaveBeenCalled ( ) ;
48
58
} ) ;
49
59
} ) ;
50
60
} ) ;
0 commit comments