本文整理汇总了TypeScript中react-hooks-testing-library.renderHook函数的典型用法代码示例。如果您正苦于以下问题:TypeScript renderHook函数的具体用法?TypeScript renderHook怎么用?TypeScript renderHook使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了renderHook函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it('includes a "close" function which sets isOpen to false', () => {
const { result } = renderHook(() => useOpenClose());
act(() => result.current.open());
expect(result.current.isOpen).toBe(true);
act(() => result.current.close());
expect(result.current.isOpen).toBe(false);
});
开发者ID:linode,项目名称:manager,代码行数:8,代码来源:useOpenClose.test.ts
示例2: it
it('should provide Loki syntax when used', async () => {
const { result, waitForNextUpdate } = renderHook(() => useLokiSyntax(languageProvider, DataSourceStatus.Connected));
expect(result.current.syntax).toEqual(null);
await waitForNextUpdate();
expect(result.current.syntax).toEqual(languageProvider.getSyntax());
});
开发者ID:grafana,项目名称:grafana,代码行数:8,代码来源:useLokiSyntax.test.ts
示例3: it
it('should not force refresh labels after a connect', () => {
const datasource = {
metadataRequest: () => ({ data: { data: [] as any[] } }),
};
const languageProvider = new LanguageProvider(datasource);
languageProvider.refreshLogLabels = jest.fn();
renderHook(() =>
useLokiLabels(languageProvider, true, [], DataSourceStatus.Disconnected, DataSourceStatus.Connected)
);
expect(languageProvider.refreshLogLabels).not.toBeCalled();
});
开发者ID:grafana,项目名称:grafana,代码行数:13,代码来源:useLokiLabels.test.ts
示例4: renderHook
const renderUseHostIpToNameHook = () =>
renderHook(props => useHostIpToName(props.ipAddress, props.indexPattern), {
initialProps: { ipAddress: '127.0.0.1', indexPattern: 'metricbest-*' },
});
开发者ID:elastic,项目名称:kibana,代码行数:4,代码来源:use_host_ip_to_name.test.ts
注:本文中的react-hooks-testing-library.renderHook函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论