本文整理汇总了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);
}
});
});
示例2: it
it('scryRenderedComponentsWithType', () => {
const component = ReactTestUtils.renderIntoDocument(React.createElement(TestComponent));
ReactTestUtils.scryRenderedComponentsWithType(component, TestComponent);
});