@@ -410,4 +410,53 @@ describe('zoid happy cases', () => {
410
410
} ) ;
411
411
} ) ;
412
412
} ) ;
413
+
414
+ it ( 'should render a component into the shadow dom' , ( ) => {
415
+ return wrapPromise ( ( { expect } ) => {
416
+
417
+ window . __component__ = ( ) => {
418
+ return window . zoid . create ( {
419
+ tag : 'test-render-shadow-dom' ,
420
+ url : 'mock://www.child.com/base/test/windows/child/index.htm' ,
421
+ domain : 'mock://www.child.com'
422
+ } ) ;
423
+ } ;
424
+
425
+ onWindowOpen ( ) . then ( expect ( 'onWindowOpen' , win => {
426
+ if ( getParent ( win ) !== window ) {
427
+ throw new Error ( `Expected window parent to be current window` ) ;
428
+ }
429
+ } ) ) ;
430
+
431
+ const body = document . body ;
432
+
433
+ if ( ! body ) {
434
+ throw new Error ( `Expected body to be present` ) ;
435
+ }
436
+
437
+ const testElement = document . createElement ( 'div' ) ;
438
+ body . appendChild ( testElement ) ;
439
+
440
+ if ( ! testElement . attachShadow ) {
441
+ throw new Error ( `Expected testElement to have attachShadow` ) ;
442
+ }
443
+
444
+ testElement . attachShadow ( { mode : 'open' } ) ;
445
+ const container = document . createElement ( 'div' ) ;
446
+
447
+ if ( ! testElement . shadowRoot ) {
448
+ throw new Error ( `Expected testElement to have shadowRoot` ) ;
449
+ }
450
+
451
+ testElement . shadowRoot . appendChild ( container ) ;
452
+
453
+ const component = window . __component__ ( ) ;
454
+ return component ( {
455
+ onRendered : expect ( 'onRendered' , ( ) => {
456
+ body . removeChild ( testElement ) ;
457
+ } )
458
+ } ) . render ( container ) ;
459
+ } ) ;
460
+ } ) ;
461
+
413
462
} ) ;
0 commit comments