Skip to content

Commit

Permalink
deps: Move from enzyme to react-test-renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
Betree committed Jan 4, 2023
1 parent d736d52 commit beb541a
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 1,246 deletions.
12 changes: 6 additions & 6 deletions app/components/Utils/__tests__/__snapshots__/Icon.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ exports[`other props get passed to container 1`] = `
className="icon"
title="Add some stuff"
>
<RawIcon
name="plus"
<i
className="fa icon-plus"
/>
</span>
`;
Expand All @@ -15,8 +15,8 @@ exports[`render icon 1`] = `
<span
className="icon"
>
<RawIcon
name="plus"
<i
className="fa icon-plus"
/>
</span>
`;
Expand All @@ -25,8 +25,8 @@ exports[`set size 1`] = `
<span
className="icon is-large"
>
<RawIcon
name="plus"
<i
className="fa icon-plus"
/>
</span>
`;
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`user doesn't have required reputation 1`] = `
<ForwardRef
contentStyle={
Object {
"maxWidth": 250,
"zIndex": 999,
}
}
on="hover"
position="bottom center"
trigger={
<div
className="help-tooltip-trigger"
>
Has reputation: false
</div>
}
<div
aria-describedby="popup-1"
className="help-tooltip-trigger"
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<Message
type="primary"
>
<Icon
name="info-circle"
/>
<Trans
i18nKey="errors:client.needReputation"
requiredRep={42}
>
You need at least
<Component />
<Link
onlyActiveOnIndex={false}
style={Object {}}
to="/help/reputation"
>
translated[pages.reputation]
</Link>
points to do that
</Trans>
</Message>
</ForwardRef>
Has reputation: false
</div>
`;

exports[`user have required reputation 1`] = `"Has reputation: true"`;
17 changes: 6 additions & 11 deletions dev/tests_setup.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import Enzyme, { shallow, render, mount } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
/**
* render: lets us render the component as React would
* screen: a utility for finding elements the same way the user does
*/
import renderer from 'react-test-renderer'
import React from 'react'
import 'isomorphic-fetch'
import 'fetch-mock'

global.React = React

// React 16 Enzyme adapter
Enzyme.configure({ adapter: new Adapter() })

// Configure global env variables
process.env.HTTP_API_URL = 'http://test'
process.env.INVITATION_SYSTEM = 'off'

// Make Enzyme functions available in all test files without importing
global.shallow = shallow
global.render = render
global.mount = mount

// Add a helper to register snapshot
global.snapshot = (element) => expect(element).toMatchSnapshot()

// Shallow then snapshot component
global.snapshotComponent = (component) => snapshot(shallow(component))
global.snapshotComponent = (component) => snapshot(renderer.create(component).toJSON())

/**
* Apply all actions to given reducer and make a snapshot at each step.
Expand Down
Loading

0 comments on commit beb541a

Please sign in to comment.