import should from "should" ; import Adapt from "../../src" ; import * as jsx from "../../src/jsx" ; import { makeObserverManagerDeployment } from "../../src/observers" ; export function checkChildComponents ( element , ... children ) { const childArray = jsx . childrenToArray ( element . props . children ) ; const childComponents = childArray . map ( ( child ) => { if ( Adapt . isElement ( child ) ) { return child . componentType ; } else { return undefined ; } } ) ; should ( childComponents ) . eql ( children ) ; } export class Empty extends Adapt . PrimitiveComponent < { id : number ; } & Adapt . WithChildren > { } export function MakeMakeEmpty ( props ) { return < MakeEmpty id = { props . id } />; } export function MakeEmpty ( props ) { return < Empty id = { props . id } />; } export function MakeGroup ( props ) { return < Adapt . Group > { props . children } < /Adapt.Group>; } export interface WithDefaultsProps { prop1 : number ; prop2 : number ; } export class WithDefaults extends Adapt . Component < WithDefaultsProps > { static defaultProps = { prop1 : 100 , prop2 : 200 , } ; build ( ) { return ( < Adapt . Group > < Empty key = "1" id = { this . props . prop1 ! } / > < Empty key = "2" id = { this . props . prop2 ! } / > < /Adapt.Group>); } } const noStoreConstructorData = { deployInfo : { deployID : "mockdeploy" , deployOpID : 0 , } , getState : ( ) => ( { } ) , setInitialState : ( ) => { } , stateUpdates : [ ] , observerManager : makeObserverManagerDeployment ( { } ) } ; export function componentConstructorDataFixture ( ccData = noStoreConstructorData ) { ccData . observerManager = makeObserverManagerDeployment ( { } ) ; before ( ( ) => jsx . pushComponentConstructorData ( ccData ) ) ; after ( ( ) => jsx . popComponentConstructorData ( ) ) ; } export class Info extends Adapt . PrimitiveComponent < Adapt . AnyProps > { } export interface MethodValueProps { target : Adapt . Handle ; method : string ; args ? : any [ ] ; default ? : any ; } export function MethodValue ( props ) { const def = "default" in props ? props . default : "DEFAULT" ; const args = props . args || [ ] ; const val = Adapt . useMethod ( props . target , def , props . method , ... args ) ; return < Info value = { val } />; }