Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

chore(package): update Enzyme #1469

Merged
merged 2 commits into from
Jun 10, 2019
Merged

chore(package): update Enzyme #1469

merged 2 commits into from
Jun 10, 2019

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Jun 7, 2019

Cut from #1459.

Problem

ThemeProvider was part of produced tree by Enzyme, it means that we should always should to call .find() method to get actual Button component. Also, with fela upgrade ThemeProvider become stateless component and it was impossible to use .state() method of Enzyme anymore.

Solution

Use wrappingComponent component option of shallow/mount that was introduced in new versions of Enzyme.

https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md#shallownode-options--shallowwrapper

Before update

    <ThemeProvider theme={{...}} overwrite={false}>
      <Button disabled={true} onClick={[Function: mockConstructor]} as="button" accessibility={[Function: buttonB
ehavior]}>
        <button className="ui-button" disabled={true} onClick={[Function]} onFocus={[Function]} role={[undefined]
} aria-disabled={true} />
      </Button>
    </ThemeProvider>

After update

    <Button disabled={true} onClick={[Function: mockConstructor]} as="button" accessibility={[Function: buttonBeh
avior]}>
      <button className="ui-button" disabled={true} onClick={[Function]} onFocus={[Function]} role={[undefined]}
aria-disabled={true} />
    </Button>

@@ -56,7 +54,7 @@ export default (Component, options: Conformant = {}) => {
const componentType = typeof Component

const helperComponentNames = [
...[ThemeProvider, FelaTheme, Ref, RefFindNode],
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -1075,7 +1075,7 @@ describe('Dropdown', () => {

expect(wrapper.find(Dropdown).state('searchQuery')).toBe('foo')

wrapper.setProps({ children: <Dropdown items={items} search searchQuery="bar" /> })
Copy link
Member Author

Choose a reason for hiding this comment

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

This update also eliminates this craziness: previously we should update whole tree...

wrapper: wrapperWrapper,
portal: wrapper,
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This stuff was removed to make tests more clear

@layershifter layershifter marked this pull request as ready for review June 7, 2019 10:51
@DustyTheBot
Copy link
Collaborator

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.

Generated by 🚫 dangerJS

@codecov
Copy link

codecov bot commented Jun 7, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@6487506). Click here to learn what that means.
The diff coverage is 90.9%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #1469   +/-   ##
=========================================
  Coverage          ?   73.45%           
=========================================
  Files             ?      806           
  Lines             ?     6088           
  Branches          ?     1798           
=========================================
  Hits              ?     4472           
  Misses            ?     1610           
  Partials          ?        6
Impacted Files Coverage Δ
.../specs/commonTests/htmlIsAccessibilityCompliant.ts 100% <100%> (ø)
packages/react/test/utils/withProvider.tsx 100% <100%> (ø)
...ages/react/test/specs/commonTests/isConformant.tsx 92.41% <85.71%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6487506...8fa1bd0. Read the comment docs.

@@ -408,7 +405,7 @@ export default (Component, options: Conformant = {}) => {
'data-simulate-event-here': true,
}

const component = mount(<Component {...props} />).childAt(0)
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need this because ThemeProvider is now outside the tree

@layershifter layershifter merged commit ef8e855 into master Jun 10, 2019
@delete-merged-branch delete-merged-branch bot deleted the chore/enzyme-update branch June 10, 2019 15:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants