Skip to content

Commit

Permalink
[New] mount/shallow: .name(): call into adapter’s `displayNameO…
Browse files Browse the repository at this point in the history
…fNode`, if present
  • Loading branch information
jquense authored and ljharb committed Jul 2, 2018
1 parent 6c3bbd1 commit 489cb56
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion packages/enzyme/src/ReactWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,10 @@ class ReactWrapper {
* @returns {String}
*/
name() {
return this.single('name', n => displayNameOfNode(n));
const adapter = getAdapter(this[OPTIONS]);
return this.single('name', n => (
adapter.displayNameOfNode ? adapter.displayNameOfNode(n) : displayNameOfNode(n)
));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,10 @@ class ShallowWrapper {
* @returns {String}
*/
name() {
return this.single('name', n => displayNameOfNode(n));
const adapter = getAdapter(this[OPTIONS]);
return this.single('name', n => (
adapter.displayNameOfNode ? adapter.displayNameOfNode(n) : displayNameOfNode(n)
));
}

/**
Expand Down

0 comments on commit 489cb56

Please sign in to comment.