@@ -38,4 +38,72 @@ describe("Drawer.vue", () => {
38
38
expect ( wrapper . find ( ".vue-simple-drawer" ) . isVisible ( ) ) . toBeTruthy ( ) ;
39
39
expect ( wrapper . find ( ".mask" ) . exists ( ) ) . not . toBeTruthy ( ) ;
40
40
} ) ;
41
+
42
+ it ( "renders props with close event" , ( ) => {
43
+ const wrapper = shallowMount ( Drawer , {
44
+ propsData : { mask : false , closeable : true , maskClosable : true } ,
45
+ slots : {
46
+ default : "<div>hello</div>"
47
+ }
48
+ } ) ;
49
+ const stub = jest . fn ( ) ;
50
+ wrapper . vm . $on ( "close" , stub ) ;
51
+ wrapper . find ( ".close-btn" ) . trigger ( "click" ) ;
52
+ expect ( stub ) . toHaveBeenCalled ( ) ;
53
+ } ) ;
54
+
55
+ it ( "renders props with close by mask event" , ( ) => {
56
+ const wrapper = shallowMount ( Drawer , {
57
+ propsData : { mask : true , closeable : true , maskClosable : true } ,
58
+ slots : {
59
+ default : "<div>hello</div>"
60
+ }
61
+ } ) ;
62
+ const stub = jest . fn ( ) ;
63
+ wrapper . vm . $on ( "close" , stub ) ;
64
+ wrapper . find ( ".mask" ) . trigger ( "click" ) ;
65
+ expect ( stub ) . toHaveBeenCalled ( ) ;
66
+ } ) ;
67
+
68
+ it ( "renders props with maskClosable as false" , ( ) => {
69
+ const wrapper = shallowMount ( Drawer , {
70
+ propsData : { mask : true , closeable : true , maskClosable : false } ,
71
+ slots : {
72
+ default : "<div>hello</div>"
73
+ }
74
+ } ) ;
75
+ const stub = jest . fn ( ) ;
76
+ wrapper . vm . $on ( "close" , stub ) ;
77
+ wrapper . find ( ".mask" ) . trigger ( "click" ) ;
78
+ expect ( stub ) . not . toHaveBeenCalled ( ) ;
79
+ } ) ;
80
+
81
+ it ( "renders props with zIndex as 10002" , ( ) => {
82
+ const wrapper = shallowMount ( Drawer , {
83
+ propsData : {
84
+ mask : true ,
85
+ closeable : true ,
86
+ maskClosable : false ,
87
+ zIndex : 10002
88
+ } ,
89
+ slots : {
90
+ default : "<div>hello</div>"
91
+ }
92
+ } ) ;
93
+ expect ( wrapper . vm . computedIndex ) . toEqual ( 10002 ) ;
94
+ } ) ;
95
+
96
+ it ( "renders props with zIndex as default" , ( ) => {
97
+ const wrapper = shallowMount ( Drawer , {
98
+ propsData : {
99
+ mask : true ,
100
+ closeable : true ,
101
+ maskClosable : false
102
+ } ,
103
+ slots : {
104
+ default : "<div>hello</div>"
105
+ }
106
+ } ) ;
107
+ expect ( wrapper . vm . computedIndex ) . toEqual ( 1000 ) ;
108
+ } ) ;
41
109
} ) ;
0 commit comments