Skip to content

Conversation

@tagoro9
Copy link
Contributor

@tagoro9 tagoro9 commented Dec 14, 2017

Always convert the name to string when in ShallowTestWrapper#inspect and ReactTestWrapper#inspect so it still works for components that have a Symbol as a displayName.

Since name is always gonna be defined I think it is fine to just call .toString, although some logic could be added to look for just Symbol instances.

#214

inspect () {
const root = this.root()
const name = root.name() || '???'
const name = (root.name() || '???').toString()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String(x) is always better than x.toString()

const rootInstance = root.instance()
const rootType = rootInstance && rootInstance.constructor
const name = rootType ? getDisplayName(rootType) : (root.name() || '???')
const name = (rootType ? getDisplayName(rootType) : (root.name() || '???')).toString()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here

expect(String(inspect(shallow(<DisplayNameSyntax />).find('div')))).to.equal('the node in <DisplayNameSyntax />')
expect(String(inspect(shallow(<DisplayNameSyntax />).find('span')))).to.equal('the node in <DisplayNameSyntax />')
expect(String(inspect(shallow(<div />)))).to.equal('<div />')
expect(String(inspect(shallow(<SymbolComponent />)))).to.equal(`<${SymbolComponent.displayName.toString()} />`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

@ayrton ayrton merged commit 4ce3bac into enzymejs:master Dec 20, 2017
@tagoro9 tagoro9 deleted the bug_with_fragments branch March 26, 2018 16:20
@eugenet8k
Copy link

Oh, thanks for fixing! I wish there would be a new release with this fix included...

eugenet8k added a commit to lookout/chai-enzyme that referenced this pull request Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants