@@ -16,33 +16,50 @@ describe('Unit testing for SwitchApp.jsx', () => {
16
16
17
17
const state = {
18
18
currentTab : 100 ,
19
- tabs : { 100 : { snapshots : [ 1 , 2 , 3 , 4 ] , viewIndex : 1 , sliderIndex : 1 } } ,
19
+ tabs : { 100 : { snapshots : [ 1 , 2 , 3 , 4 ] , viewIndex : 1 , sliderIndex : 1 , title : 'component' } } ,
20
20
} ;
21
- const tabsArray = [ ] ;
22
- const currTab = {
21
+ const tabsArray = [ { value : 100 , label : { } } ] ;
22
+ const dropdownCurrTabLabel = {
23
23
value : 100 ,
24
24
label : { } ,
25
25
} ;
26
-
26
+ // nate and edwin: mockImplementation creates a mock function call
27
27
const dispatch = jest . fn ( ) ;
28
- useStoreContext . mockImplementation ( ( ) => [ dispatch , state ] ) ;
28
+ // nate and edwin: mockImplementation creates a mock state
29
+ useStoreContext . mockImplementation ( ( ) => [ state , dispatch ] ) ;
29
30
30
31
beforeEach ( ( ) => {
31
32
wrapper = shallow ( < SwitchApp /> ) ;
32
33
} ) ;
33
34
34
- describe ( 'currentTab' , ( ) => {
35
+ describe ( 'SwitchApp Component' , ( ) => {
36
+ it ( 'SwitchApp component returns <Select /> from react-select library' , ( ) => {
37
+ expect ( wrapper . find ( '.tab-select-container' ) . type ( ) ) . toEqual ( Select ) ;
38
+ expect ( wrapper . find ( '.tab-select-container' ) . props ( ) . className ) . toBe ( 'tab-select-container' ) ;
39
+ expect ( Array . isArray ( wrapper . find ( '.tab-select-container' ) . props ( ) . options ) ) . toBeTruthy ( ) ;
40
+ expect ( wrapper . find ( '.tab-select-container' ) . props ( ) . options [ 0 ] ) . toHaveProperty ( 'value' ) ;
41
+ expect ( wrapper . find ( '.tab-select-container' ) . props ( ) . options [ 0 ] ) . toHaveProperty ( 'label' ) ;
42
+ expect ( wrapper . find ( '.tab-select-container' ) . props ( ) ) . toEqual ( state . currentTab . value ) ;
43
+ } ) ;
44
+ } )
45
+
46
+ describe ( 'dropdownCurrTabLabel' , ( ) => {
35
47
it ( 'should have properties value and label' , ( ) => {
36
- expect ( currTab ) . toHaveProperty ( 'value' ) ;
37
- expect ( currTab ) . toHaveProperty ( 'label' ) ;
48
+ expect ( dropdownCurrTabLabel ) . toHaveProperty ( 'value' ) ;
49
+ expect ( dropdownCurrTabLabel ) . toHaveProperty ( 'label' ) ;
50
+ } ) ;
51
+ } ) ;
52
+
53
+ describe ( 'state' , ( ) => {
54
+ it ( 'currentTab value should be a number' , ( ) => {
55
+ expect ( typeof state . currentTab ) . toEqual ( 'number' ) ;
56
+ } ) ;
57
+ it ( 'tabs value should be an object' , ( ) => {
58
+ expect ( typeof state . tabs ) . toEqual ( 'object' ) ;
38
59
} ) ;
39
60
} ) ;
40
61
41
- // check if currTab has properties value, label
42
- // currentTab should be a number
43
- // tab should be an object
44
- // check if onChange if the function runs
45
- // className should be tab-select-container
46
- // options should be an array
47
- // value prop should be equal to a number
62
+ // options should be an array
63
+ // value prop should be equal to a number
64
+ // check if onChange if the function runs
48
65
} )
0 commit comments