1.0.2 • Published 5 years ago

@lugia/react-test-utils v1.0.2

Weekly downloads
3
License
-
Repository
-
Last release
5 years ago

说明

这是一个用于快速创建测试组件的工具包

delay

    delay (time: number, callback?: Function): Promise<any>;

延迟工具方法,将setTimeout操作封装成一个Promise,方便测试使用。callback为定时器到达后要调用的方法。而Promise的结果为,callback返回的结果

createTestComponent

 createTestComponent
    (Target: React.ComponentType<any>,
     callback: (Object) => void, live?: LiveMethod): React.ComponentType<any>;

根据指定的React.Component创建一个新的组件,然后勾住响应的声明周期。

  • callback是在组件mount以后,将目标组件的ref绑定回调给方法
  • live是用来勾住各类声明周期,目前支持以下声明周期
 declare type LiveMethod = {
    componentWillReceiveProps?: Function,
    componentDidUpdate?: Function,
    shouldComponentUpdate?: Function,
  }
1.0.2

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago