Skip to content

Latest commit

 

History

History
36 lines (24 loc) · 936 Bytes

name.md

File metadata and controls

36 lines (24 loc) · 936 Bytes

.name() => String|null

Returns the name of the current node of this wrapper. If it's a composite component, this will be the name of the top-most rendered component. If it's native DOM node, it will be a string of the tag name. If it's null, it will be null.

The order of precedence on returning the name is: type.displayName -> type.name -> type.

Note: can only be called on a wrapper of a single node.

Returns

String|null: The name of the current node

Examples

const wrapper = shallow(<div/>);
expect(wrapper.name()).to.equal('div');
const SomeWrappingComponent = () => <Foo />;
const wrapper = shallow(<SomeWrappingComponent />);
expect(wrapper.name()).to.equal('Foo');
Foo.displayName = 'A cool custom name';
const SomeWrappingComponent = () => <Foo />;
const wrapper = shallow(<SomeWrappingComponent />);
expect(wrapper.name()).to.equal('A cool custom name');