Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null instead of Object {} for imported css #108

Open
ashgaliyev opened this issue Jun 4, 2018 · 2 comments
Open

null instead of Object {} for imported css #108

ashgaliyev opened this issue Jun 4, 2018 · 2 comments
Labels

Comments

@ashgaliyev
Copy link

Hello! I've recently upgraded from 1.5.1 to 3.3.4 and saw that all properties that get css files have been rewritten from Object {} to null

I didn't find this change in the changelog and maybe it is a bug?

here is an example:

import React from 'react';
import LinkInner from './LinkInner';
import styles from './style.css';

class Link extends React.Component {
  render() {
    return (
      <a href={this.props.page || '#'}>
        <LinkInner theme={styles} />
      </a>
    );
  }
}

export default Link;

test:

import React from 'react';
import Link from './Link';
import { shallow } from 'enzyme';

it('renders correctly', () => {
  const component = shallow(<Link page="http://www.facebook.com">Facebook</Link>);
  expect(component).toMatchSnapshot();
});

snapshot:

exports[`renders correctly 1`] = `
<a
  href="http://www.facebook.com"
>
  <LinkInner
    theme={null}
  />
</a>
`;
@ashgaliyev
Copy link
Author

ashgaliyev commented Jun 13, 2018

There is return null in the new code of enzyme-to-json which wasn't before.
If it gets object other than the react component (style object this our case) it will return null.
https://github.com/adriantoine/enzyme-to-json/blob/master/src/shallow.js#L62

in the old code it returns empty object
https://github.com/adriantoine/enzyme-to-json/blob/v1.5.1/src/shallow.js#L10

correct me if I'm wrong

@VincentLanglet
Copy link
Collaborator

PR are welcomed.

Prior to null behaviour, you had just an empty object ?
I would be better to have the complete object with the style property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants