Updated enzyme to 2.4.1

This commit is contained in:
Alexey Svetliakov
2016-07-09 06:11:53 +02:00
parent ea054545ee
commit f77d4a03c4
2 changed files with 62 additions and 3 deletions
+23
View File
@@ -44,6 +44,15 @@ namespace ShallowWrapperTest {
stringVal: String,
elementWrapper: ShallowWrapper<HTMLAttributes, {}>
function test_shallow_options() {
shallow(<MyComponent propsProperty={1}/>, {
context: {
test: "a",
lifecycleExperimental: true
}
});
}
function test_find() {
elementWrapper = shallowWrapper.find('.selector');
shallowWrapper = shallowWrapper.find(MyComponent);
@@ -281,6 +290,10 @@ namespace ShallowWrapperTest {
function test_everyWhere() {
boolVal = shallowWrapper.everyWhere((aShallowWrapper: ShallowWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_isEmptyRender() {
boolVal = shallowWrapper.isEmptyRender();
}
}
@@ -301,6 +314,13 @@ namespace ReactWrapperTest {
function test_mount() {
reactWrapper = reactWrapper.mount();
mount(<MyComponent propsProperty={1}/>, {
attachTo: document.getElementById('test'),
context: {
a: "b"
}
});
}
function test_ref() {
@@ -542,6 +562,9 @@ namespace ReactWrapperTest {
function test_everyWhere() {
boolVal = reactWrapper.everyWhere((aReactWrapper: ReactWrapper<MyComponentProps, MyComponentState>) => true);
}
function test_isEmptyRender() {
boolVal = reactWrapper.isEmptyRender();
}
}
// CheerioWrapper
+39 -3
View File
@@ -1,4 +1,4 @@
// Type definitions for Enzyme v2.3.0
// Type definitions for Enzyme v2.4.1
// Project: https://github.com/airbnb/enzyme
// Definitions by: Marian Palkus <https://github.com/MarianPalkus>, Cap3 <http://www.cap3.de>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -448,6 +448,11 @@ declare module "enzyme" {
* Returns a wrapper with the direct parent of the node in the current wrapper.
*/
parent(): ShallowWrapper<any, any>;
/**
* Returns true if renderer returned null
*/
isEmptyRender(): boolean;
}
export interface ReactWrapper<P, S> extends CommonWrapper<P, S> {
@@ -544,26 +549,57 @@ declare module "enzyme" {
* Returns a wrapper with the direct parent of the node in the current wrapper.
*/
parent(): ReactWrapper<any, any>;
/**
* Returns true if renderer returned null
*/
isEmptyRender(): boolean;
}
export interface CheerioWrapper<P, S> extends CommonWrapper<P, S> {
}
export interface ShallowRendererProps {
/**
* Enable experimental support for full react lifecycle methods
*/
lifecycleExperimental?: boolean;
/**
* Context to be passed into the component
*/
context?: {};
}
export interface MountRendererProps {
/**
* Context to be passed into the component
*/
context?: {};
/**
* DOM Element to attach the component to
*/
attachTo?: HTMLElement;
/**
* Merged contextTypes for all children of the wrapper
*/
childContextTypes?: {};
}
/**
* Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that
* your tests aren't indirectly asserting on behavior of child components.
* @param node
* @param [options]
*/
export function shallow<P, S>(node: ReactElement<P>, options?: any): ShallowWrapper<P, S>;
export function shallow<P, S>(node: ReactElement<P>, options?: ShallowRendererProps): ShallowWrapper<P, S>;
/**
* Mounts and renders a react component into the document and provides a testing wrapper around it.
* @param node
* @param [options]
*/
export function mount<P, S>(node: ReactElement<P>, options?: any): ReactWrapper<P, S>;
export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps): ReactWrapper<P, S>;
/**
* Render react components to static HTML and analyze the resulting HTML structure.