File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed
packages/mui-component-mapper/src/tests Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { mount } from 'enzyme' ;
3
+ import AppBar from '@material-ui/core/AppBar' ;
4
+ import Tabs from '@material-ui/core/Tabs' ;
5
+ import Tab from '@material-ui/core/Tab' ;
6
+
7
+ import FormTabs from '../form-fields/tabs' ;
8
+
9
+ describe ( 'tabs' , ( ) => {
10
+ const props = {
11
+ fields : [
12
+ {
13
+ key : 'cosiKey' ,
14
+ title : 'cosiTitle' ,
15
+ name : 'cosiName' ,
16
+ fields : [ ] ,
17
+ } ,
18
+ {
19
+ key : 'cosiKey2' ,
20
+ title : 'cosiTitle2' ,
21
+ name : 'cosiName2' ,
22
+ fields : [ ] ,
23
+ } ,
24
+ ] ,
25
+ formOptions : {
26
+ renderForm : jest . fn ( ) . mockImplementation ( ( ) => < h1 > Content</ h1 > ) ,
27
+ } ,
28
+ } ;
29
+
30
+ it ( 'should render tabs correctly' , ( ) => {
31
+ const wrapper = mount ( < FormTabs { ...props } /> ) ;
32
+
33
+ expect ( wrapper . find ( AppBar ) ) . toHaveLength ( 1 ) ;
34
+ expect ( wrapper . find ( Tabs ) ) . toHaveLength ( 1 ) ;
35
+ expect ( wrapper . find ( Tab ) ) . toHaveLength ( 2 ) ;
36
+ expect ( wrapper . find ( 'h1' ) ) . toHaveLength ( 1 ) ;
37
+ } ) ;
38
+
39
+ it ( 'should switch tabs correctly' , ( ) => {
40
+ const wrapper = mount ( < FormTabs { ...props } /> ) ;
41
+ expect ( wrapper . instance ( ) . state . activeTab ) . toEqual ( 0 ) ;
42
+
43
+ const secondTabButton = wrapper . find ( 'button' ) . last ( ) ;
44
+ secondTabButton . simulate ( 'click' ) ;
45
+
46
+ expect ( wrapper . instance ( ) . state . activeTab ) . toEqual ( 1 ) ;
47
+ } ) ;
48
+ } ) ;
You can’t perform that action at this time.
0 commit comments