@@ -16,11 +16,16 @@ describe('Trigger.Point', () => {
16
16
} ) ;
17
17
18
18
class Demo extends React . Component {
19
- popup = < div className = "point-popup" > POPUP</ div > ;
19
+ popup = ( < div className = "point-popup" > POPUP</ div > ) ;
20
20
21
21
render ( ) {
22
22
return (
23
- < Trigger popup = { this . popup } popupAlign = { { points : [ 'tl' ] } } alignPoint { ...this . props } >
23
+ < Trigger
24
+ popup = { this . popup }
25
+ popupAlign = { { points : [ 'tl' ] } }
26
+ alignPoint
27
+ { ...this . props }
28
+ >
24
29
< div className = "point-region" />
25
30
</ Trigger >
26
31
) ;
@@ -36,7 +41,9 @@ describe('Trigger.Point', () => {
36
41
. first ( )
37
42
. getDOMNode ( ) ;
38
43
39
- expect ( popup . style ) . toEqual ( expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ) ;
44
+ expect ( popup . style ) . toEqual (
45
+ expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ,
46
+ ) ;
40
47
} ) ;
41
48
42
49
it ( 'hover' , ( ) => {
@@ -48,33 +55,59 @@ describe('Trigger.Point', () => {
48
55
. first ( )
49
56
. getDOMNode ( ) ;
50
57
51
- expect ( popup . style ) . toEqual ( expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ) ;
58
+ expect ( popup . style ) . toEqual (
59
+ expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ,
60
+ ) ;
52
61
} ) ;
53
62
54
63
describe ( 'contextMenu' , ( ) => {
55
64
it ( 'basic' , ( ) => {
56
- const wrapper = mount ( < Demo action = { [ 'contextMenu' ] } /> ) ;
65
+ const wrapper = mount (
66
+ < Demo action = { [ 'contextMenu' ] } hideAction = { [ 'click' ] } /> ,
67
+ ) ;
57
68
wrapper . trigger ( 'contextMenu' , { pageX : 10 , pageY : 20 } ) ;
58
69
59
70
const popup = wrapper
60
71
. find ( '.rc-trigger-popup' )
61
72
. first ( )
62
73
. getDOMNode ( ) ;
63
74
64
- expect ( popup . style ) . toEqual ( expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ) ;
75
+ expect ( popup . style ) . toEqual (
76
+ expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ,
77
+ ) ;
78
+
79
+ // Not trigger point update when close
80
+ const clickEvent = { } ;
81
+ const pagePropDefine = {
82
+ get : ( ) => {
83
+ throw new Error ( 'should not read when close' ) ;
84
+ } ,
85
+ } ;
86
+ Object . defineProperties ( clickEvent , {
87
+ pageX : pagePropDefine ,
88
+ pageY : pagePropDefine ,
89
+ } ) ;
90
+ wrapper
91
+ . find ( 'Trigger' )
92
+ . instance ( )
93
+ . onClick ( clickEvent ) ;
65
94
} ) ;
66
95
67
96
// https://github.com/ant-design/ant-design/issues/17043
68
97
it ( 'not prevent default' , done => {
69
- const wrapper = mount ( < Demo showAction = { [ 'contextMenu' ] } hideAction = { [ 'click' ] } /> ) ;
98
+ const wrapper = mount (
99
+ < Demo showAction = { [ 'contextMenu' ] } hideAction = { [ 'click' ] } /> ,
100
+ ) ;
70
101
wrapper . trigger ( 'contextMenu' , { pageX : 10 , pageY : 20 } ) ;
71
102
72
103
const popup = wrapper
73
104
. find ( '.rc-trigger-popup' )
74
105
. first ( )
75
106
. getDOMNode ( ) ;
76
107
77
- expect ( popup . style ) . toEqual ( expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ) ;
108
+ expect ( popup . style ) . toEqual (
109
+ expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ,
110
+ ) ;
78
111
79
112
// Click to close
80
113
wrapper . trigger ( 'click' , {
@@ -91,7 +124,11 @@ describe('Trigger.Point', () => {
91
124
function testPlacement ( name , builtinPlacements , afterAll ) {
92
125
it ( name , ( ) => {
93
126
const wrapper = mount (
94
- < Demo action = { [ 'click' ] } builtinPlacements = { builtinPlacements } popupPlacement = "right" /> ,
127
+ < Demo
128
+ action = { [ 'click' ] }
129
+ builtinPlacements = { builtinPlacements }
130
+ popupPlacement = "right"
131
+ /> ,
95
132
) ;
96
133
wrapper . trigger ( 'click' , { pageX : 10 , pageY : 20 } ) ;
97
134
@@ -100,7 +137,9 @@ describe('Trigger.Point', () => {
100
137
. first ( )
101
138
. getDOMNode ( ) ;
102
139
103
- expect ( popup . style ) . toEqual ( expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ) ;
140
+ expect ( popup . style ) . toEqual (
141
+ expect . objectContaining ( { left : '-989px' , top : '-979px' } ) ,
142
+ ) ;
104
143
105
144
if ( afterAll ) {
106
145
afterAll ( wrapper ) ;
@@ -124,7 +163,9 @@ describe('Trigger.Point', () => {
124
163
} ,
125
164
wrapper => {
126
165
expect (
127
- wrapper . find ( 'div.rc-trigger-popup' ) . hasClass ( 'rc-trigger-popup-placement-left' ) ,
166
+ wrapper
167
+ . find ( 'div.rc-trigger-popup' )
168
+ . hasClass ( 'rc-trigger-popup-placement-left' ) ,
128
169
) . toBeTruthy ( ) ;
129
170
} ,
130
171
) ;
0 commit comments