import { expect } from "chai" ; import AemTest from "./AemTest" ; import * as enzyme from "enzyme" ; import { ResourceComponent } from "../component/ResourceComponent" ; import * as React from "react" ; import { ReactWrapper } from "enzyme" ; import ComponentRegistry from "../ComponentRegistry" ; import ReactParsys from "../component/ReactParsys" ; import AemLink from "../router/AemLink" ; import { Router , Route , createMemoryHistory } from "react-router" ; import { ShallowWrapper } from "enzyme" ; import { History , MemoryHistoryOptions } from "history" ; describe ( "AemLink" , ( ) => { let index = { entries : "/index.html" } ; let history = createMemoryHistory ( index ) ; class LinkComponent extends React . Component < any , any > { public render ( ) { return ( < span > < AemLink to = "/bla.html" > hallo < /AemLink> < /span>); } } class RouterComponent extends ResourceComponent < any , any , any > { public renderBody ( ) { return ( < div > < Router history = { history } > < Route path = "/index.html" component = { LinkComponent } / > < Route path = "/bla.html" component = { LinkComponent } / > < /Router> < /div>); } } let registry = new ComponentRegistry ( "/components" ) ; registry . register ( RouterComponent ) ; registry . register ( ReactParsys ) ; let aemTest = new AemTest ( ) ; aemTest . addRegistry ( registry ) ; aemTest . init ( ) ; it ( "should render AemLink in Router" , ( ) => { let wrapper = aemTest . render ( { resourceType : "/components/router-component" } ) ; expect ( wrapper . html ( ) ) . to . equal ( "<span><a href=\"/bla.html\">hallo</a></span>" ) ; } ) ; it ( "should render AemLink" , ( ) => { class MyLink extends AemLink { protected isClickable ( ) { return true ; } } let router = { } ; let history = { createLocation : function ( ) { return { pathname : "bla.html" } ; } } ; let container = { get : function ( ) { return history ; } } ; let context = { router : router , wcmmode : "disabled" , aemContext : { container : container } } ; let wrapper = enzyme . shallow ( ( < MyLink to = "bla.html" / > ) , { context : context } ) ; wrapper . simulate ( 'click' ) ; } ) ; } ) ;