当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript test-utils.scryRenderedComponentsWithType函数代码示例

本文整理汇总了TypeScript中react-dom/test-utils.scryRenderedComponentsWithType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript scryRenderedComponentsWithType函数的具体用法?TypeScript scryRenderedComponentsWithType怎么用?TypeScript scryRenderedComponentsWithType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了scryRenderedComponentsWithType函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: runReactTest

    return runReactTest(element => {
        let receivedCredentials = defer<any>();
        let authServerURL = () => 'https://acmestorage.com/oauth2/authorize';

        // render the auth dialog
        let dialog = render(
            AuthDialogF({
                authServerURL,
                onComplete: (credentials: any) =>
                    receivedCredentials.resolve(credentials),
            }),
            element
        ) as Component<auth_dialog.AuthDialogProps, {}>;

        // click on the 'Sign In' button and verify
        // that the auth dialog begins and the dialog text changes
        let buttons = scryRenderedComponentsWithType(dialog, Button) as any;
        if (clickSignIn) {
            buttons[1].props.onClick(null);
        } else {
            buttons[0].props.onClick(null);
        }

        // verify that the dialog invokes the onComplete() callback
        // with credentials once auth completes
        return receivedCredentials.promise.then(credentials => {
            if (clickSignIn) {
                assert.equal(credentials.accessToken, 'mock-auth-token');
            } else {
                assert.ok(!credentials);
            }
        });
    });
开发者ID:robertknight,项目名称:passcards,代码行数:33,代码来源:auth_dialog_test.ts

示例2: it

 it('scryRenderedComponentsWithType', () => {
     const component = ReactTestUtils.renderIntoDocument(React.createElement(TestComponent));
     ReactTestUtils.scryRenderedComponentsWithType(component, TestComponent);
 });
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:4,代码来源:react-dom-tests.ts


注:本文中的react-dom/test-utils.scryRenderedComponentsWithType函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。