Skip to content

Make displayNameOfNode return function.name even if it is falsey#878

Merged
ljharb merged 1 commit intomasterfrom
fix/displayName-falsey
Apr 10, 2017
Merged

Make displayNameOfNode return function.name even if it is falsey#878
ljharb merged 1 commit intomasterfrom
fix/displayName-falsey

Conversation

@nfcampos
Copy link
Copy Markdown
Collaborator

@nfcampos nfcampos commented Apr 10, 2017

previously it would return the function itself, which is strange, displayNameOfNode should return either a string or null

@ljharb this can (should?) be merged before #876

found this because the changes in #876 made us start using createClass instead of React.createClass in the tests to create createClass components, which made this babel plugin https://babeljs.io/docs/plugins/transform-react-display-name/ stop adding the variable name as displayName to these components and thus those tests started failing with AssertionError: expected [Function] to equal 'Foo' (example failure at https://travis-ci.org/airbnb/enzyme/jobs/220197356#L4836)

(the tests should probably be removed, because they seem to be testing a babel plugin instead of enzyme)

- previously it would return the function itself
@nfcampos nfcampos requested a review from ljharb April 10, 2017 06:36
expect(displayNameOfNode(<Foo />)).to.equal('Foo');
});

it('should return the name even if it is falsey', () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

falsey → falsy

nfcampos added a commit to kentcdodds/enzyme that referenced this pull request Apr 10, 2017
see PR enzymejs#878 for explanation
@nfcampos nfcampos force-pushed the fix/displayName-falsey branch 2 times, most recently from e4e04bd to a2c6d5a Compare April 10, 2017 08:17
@ljharb ljharb force-pushed the fix/displayName-falsey branch from a2c6d5a to 85447ed Compare April 10, 2017 16:03
@ljharb ljharb merged commit 85447ed into master Apr 10, 2017
@ljharb ljharb deleted the fix/displayName-falsey branch April 10, 2017 16:04
nfcampos added a commit to kentcdodds/enzyme that referenced this pull request Apr 10, 2017
see PR enzymejs#878 for explanation
ljharb pushed a commit to kentcdodds/enzyme that referenced this pull request Apr 12, 2017
ljharb pushed a commit to kentcdodds/enzyme that referenced this pull request Apr 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants