本文整理汇总了TypeScript中enzyme.mount函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mount函数的具体用法?TypeScript mount怎么用?TypeScript mount使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mount函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("renders children", () => {
const wrapper = mount(WidgetHeader({
title: "fakeWidget",
children: "children"
}));
expect(wrapper.html()).toContain("children");
});
示例2: it
it("renders", () => {
let element = mount(BackArrow());
expect(element).toBeTruthy();
expect(element.hasClass("back-arrow")).toBeTruthy();
expect(element.find("i").at(0).hasClass("fa-arrow-left"))
.toBeTruthy();
});
示例3: it
it('should properly pass down useCapture', () => {
const calls: string[] = [];
let b: any;
class Test extends React.Component<any, any> {
public onClick() {
calls.push('test');
}
public render() {
return React.createElement('button', {
onClick: () => calls.push('button'),
ref: (i: any) => b = i,
});
}
}
const element = document.createElement('div');
document.body.appendChild(element);
const Mixout = mixout(listen('click', 'onClick', { target: 'document', useCapture: true }))(Test);
mount(React.createElement(Mixout), { attachTo: element });
expect(calls).to.deep.equal([]);
b.click();
expect(calls).to.deep.equal(['test', 'button']);
});
示例4: callback
export function safeMount<TComponent extends React.Component, TProps = TComponent['props'], TState = TComponent['state']>(
content: React.ReactElement<TProps>,
callback: (wrapper: ReactWrapper<TProps, TState, TComponent>) => void
): void {
const wrapper = mount<TComponent, TProps, TState>(content);
callback(wrapper);
wrapper.unmount();
}
示例5: it
it("renders Router", () => {
const renderSpy = spy(ReactDOM, "render");
new CirculationWeb({});
expect(renderSpy.callCount).to.equal(1);
const component = renderSpy.args[0][0];
const wrapper = mount(component);
const router = wrapper.find(Router);
expect(router.length).to.equal(1);
renderSpy.restore();
});
示例6: describe
describe("<Widget />", () => {
const params = { children: "wow", className: "k" };
const result = mount(Widget(params));
it("renders correct children", () => {
expect(result.html()).toContain("wow");
});
it("renders correct classnames", () => {
const element = result.find("div");
expect(element.hasClass("k")).toBeTruthy();
expect(element.hasClass("widget-wrapper")).toBeTruthy();
});
});