Merge pull request #12860 from rhysd/fix-enzyme

enzyme: Enable enzyme-tests.ts again and fix <svg> attributes errors
This commit is contained in:
Nathan Shively-Sanders
2016-11-27 09:41:04 -08:00
committed by GitHub
2 changed files with 11 additions and 7 deletions

View File

@@ -1,4 +1,3 @@
/*
import { shallow, mount, render, describeWithDOM, spyLifecycle } from "enzyme";
import * as React from "react";
import {Component, ReactElement, HTMLAttributes} from "react";
@@ -39,7 +38,8 @@ namespace ShallowWrapperTest {
objectVal: Object,
boolVal: Boolean,
stringVal: String,
elementWrapper: ShallowWrapper<HTMLAttributes, {}>
numOrStringVal: number | string,
elementWrapper: ShallowWrapper<HTMLAttributes<{}>, {}>
function test_shallow_options() {
shallow(<MyComponent propsProperty={1}/>, {
@@ -307,6 +307,10 @@ namespace ShallowWrapperTest {
function test_isEmptyRender() {
boolVal = shallowWrapper.isEmptyRender();
}
function test_svg() {
numOrStringVal = shallowWrapper.find('svg').props().strokeWidth;
}
}
@@ -319,7 +323,7 @@ namespace ReactWrapperTest {
objectVal: Object,
boolVal: Boolean,
stringVal: String,
elementWrapper: ReactWrapper<HTMLAttributes, {}>
elementWrapper: ReactWrapper<HTMLAttributes<{}>, {}>
function test_unmount() {
reactWrapper = reactWrapper.unmount();
@@ -593,7 +597,7 @@ namespace CheerioWrapperTest {
objectVal: Object,
boolVal: Boolean,
stringVal: String,
elementWrapper: CheerioWrapper<HTMLAttributes, {}>
elementWrapper: CheerioWrapper<HTMLAttributes<{}>, {}>
function test_find() {
elementWrapper = cheerioWrapper.find('.selector');
@@ -821,4 +825,4 @@ namespace CheerioWrapperTest {
function test_everyWhere() {
boolVal = cheerioWrapper.everyWhere((aCheerioWrapper: CheerioWrapper<MyComponentProps, MyComponentState>) => true);
}
}*/
}

4
enzyme/index.d.ts vendored
View File

@@ -3,9 +3,9 @@
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>, Ivo Stratev <https://github.com/NoHomey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes as ReactHTMLAttributes } from "react";
import { ReactElement, Component, StatelessComponent, ComponentClass, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react";
type HTMLAttributes = ReactHTMLAttributes<{}>;
type HTMLAttributes = ReactHTMLAttributes<{}> & ReactSVGAttributes<{}>;
export class ElementClass extends Component<any, any> {
}