@@ -198,122 +198,3 @@ describe('Trigger.Shadow', () => {
198198 errSpy . mockRestore ( ) ;
199199 } ) ;
200200} ) ;
201-
202- describe ( 'Popup.Shadow' , ( ) => {
203- beforeEach ( ( ) => {
204- resetWarned ( ) ;
205- jest . useFakeTimers ( ) ;
206- } ) ;
207-
208- afterEach ( ( ) => {
209- jest . useRealTimers ( ) ;
210- } ) ;
211-
212- class CustomElement extends HTMLElement {
213- disconnectedCallback ( ) { }
214- connectedCallback ( ) {
215- const shadowRoot = this . attachShadow ( {
216- mode : 'open' ,
217- } ) ;
218- const container = document . createElement ( 'div' ) ;
219- shadowRoot . appendChild ( container ) ;
220- container . classList . add ( 'shadow-container' ) ;
221- container . innerHTML = `<div class="shadow-content">Hello World</div>` ;
222- }
223- }
224-
225- customElements . define ( 'custom-element' , CustomElement ) ;
226-
227- it ( 'should not close the popup when click the shadow content in the popup element' , async ( ) => {
228- const container = document . createElement ( 'div' ) ;
229- document . body . appendChild ( container ) ;
230-
231- act ( ( ) => {
232- createRoot ( container ) . render (
233- < >
234- < div className = "outer" > outer</ div >
235- < Trigger
236- action = { [ 'click' ] }
237- autoDestroy
238- popup = { < custom-element class = "popup" /> }
239- >
240- < p className = "target" />
241- </ Trigger >
242- </ > ,
243- ) ;
244- } ) ;
245-
246- await awaitFakeTimer ( ) ;
247-
248- // Click to show
249- fireEvent . click ( document . querySelector ( '.target' ) ) ;
250- await awaitFakeTimer ( ) ;
251- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
252-
253- // Click outside to hide
254- fireEvent . mouseDown ( document . querySelector ( '.outer' ) ) ;
255- await awaitFakeTimer ( ) ;
256- expect ( document . querySelector ( '.popup' ) ) . toBeFalsy ( ) ;
257-
258- // Click to show again
259- fireEvent . click ( document . querySelector ( '.target' ) ) ;
260- await awaitFakeTimer ( ) ;
261- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
262-
263- // Click on popup element should not hide
264- fireEvent . mouseDown ( document . querySelector ( '.popup' ) ) ;
265- await awaitFakeTimer ( ) ;
266- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
267-
268- // Click on shadow content should not hide
269- const popup = document . querySelector ( '.popup' ) ;
270- fireEvent . mouseDown ( popup . shadowRoot . querySelector ( '.shadow-content' ) ) ;
271- await awaitFakeTimer ( ) ;
272- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
273- } ) ;
274-
275- it ( 'should works with custom element trigger' , async ( ) => {
276- const container = document . createElement ( 'div' ) ;
277- document . body . innerHTML = '' ;
278- document . body . appendChild ( container ) ;
279-
280- act ( ( ) => {
281- createRoot ( container ) . render (
282- < >
283- < div className = "outer" > outer</ div >
284- < Trigger
285- action = { [ 'click' ] }
286- autoDestroy
287- popup = { < custom-element class = "popup" /> }
288- >
289- < custom-element class = "target" />
290- </ Trigger >
291- </ > ,
292- ) ;
293- } ) ;
294-
295- await awaitFakeTimer ( ) ;
296-
297- // Click to show
298- const target = document . querySelector ( '.target' ) ;
299- fireEvent . click ( target ) ;
300- await awaitFakeTimer ( ) ;
301- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
302-
303- // Click outside to hide
304- fireEvent . mouseDown ( document . querySelector ( '.outer' ) ) ;
305- await awaitFakeTimer ( ) ;
306- expect ( document . querySelector ( '.popup' ) ) . toBeFalsy ( ) ;
307-
308- // Click shadow content to show
309- fireEvent . click ( target . shadowRoot . querySelector ( '.shadow-content' ) ) ;
310- await awaitFakeTimer ( ) ;
311- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
312-
313- // Click on shadow content should not hide
314- const popup = document . querySelector ( '.popup' ) ;
315- fireEvent . mouseDown ( popup . shadowRoot . querySelector ( '.shadow-content' ) ) ;
316- await awaitFakeTimer ( ) ;
317- expect ( document . querySelector ( '.popup' ) ) . toBeTruthy ( ) ;
318- } ) ;
319- } ) ;
0 commit comments