import { expect } from "chai" ; import AemTest from "./AemTest" ; import { ResourceComponent } from "../component/ResourceComponent" ; import * as React from "react" ; import ComponentRegistry from "../ComponentRegistry" ; import ReactParsys from "../component/ReactParsys" ; describe ( "ReactParsys" , ( ) => { class Text extends ResourceComponent < any , any , any > { public renderBody ( ) { let text = this . getResource ( ) ? this . getResource ( ) . text : "unknown" ; return ( < span > { text } < /span>); } } let registry = new ComponentRegistry ( "/components" ) ; registry . register ( Text ) ; registry . register ( ReactParsys ) ; let aemTest = new AemTest ( ) ; aemTest . addRegistry ( registry ) ; aemTest . init ( ) ; it ( "should render ReactParsys with a single child" , ( ) => { let wrapper = aemTest . render ( { resourceType : "/components/react-parsys" , child_1 : { "sling:resourceType" : "/components/text" , text : "Hallo" } } ) ; expect ( wrapper . html ( ) ) . to . equal ( "<div class=\"dialog\"><span>Hallo</span></div>" ) ; } ) ; it ( "should render ReactParsys with no children" , ( ) => { let wrapper = aemTest . render ( { resourceType : "/components/react-parsys" , } ) ; expect ( wrapper . html ( ) ) . to . equal ( "" ) ; } ) ; } ) ;