diff --git a/react/ActionMenu/index.spec.jsx b/react/ActionMenu/index.spec.jsx
index 84ac258c90..9c43e71a08 100644
--- a/react/ActionMenu/index.spec.jsx
+++ b/react/ActionMenu/index.spec.jsx
@@ -1,12 +1,36 @@
import React from 'react'
import { mount } from 'enzyme'
-
+import { act } from 'react-dom/test-utils'
import ActionMenu, { ActionMenuItem } from './'
import { fixPopperTesting } from '../Popper/testing'
describe('ActionMenu', () => {
fixPopperTesting()
+ // The update-not-wrapping-in-act warning is disabled for ActionMenuWrapper since
+ // we have not found how to remove the "update" happening when mounting the
+ // ActionMenu.
+ let originalConsoleError = console.error
+
+ beforeEach(() => {
+ // eslint-disable-next-line no-console
+ console.error = function(msg, arg) {
+ if (
+ msg.includes('An update to %s inside a test was not wrapped in act') &&
+ arg == 'ActionMenuWrapper'
+ ) {
+ return
+ } else {
+ return originalConsoleError.apply(this, arguments)
+ }
+ }
+ })
+
+ afterEach(() => {
+ // eslint-disable-next-line no-console
+ console.error = originalConsoleError
+ })
+
it('should support null children', () => {
const comp = mount(
@@ -40,16 +64,21 @@ describe('ActionMenu', () => {
)
- comp
- .find(ActionMenuItem)
- .at(1)
- .simulate('click')
+ act(() => {
+ comp
+ .find(ActionMenuItem)
+ .at(1)
+ .simulate('click')
+ })
expect(menuAction2).toHaveBeenCalled()
expect(closeMenu).not.toHaveBeenCalled()
- comp
- .find(ActionMenuItem)
- .at(0)
- .simulate('click')
+
+ act(() => {
+ comp
+ .find(ActionMenuItem)
+ .at(0)
+ .simulate('click')
+ })
expect(menuAction1).toHaveBeenCalled()
expect(closeMenu).toHaveBeenCalled()
})
diff --git a/react/Badge/index.jsx b/react/Badge/index.jsx
index 218d3a101a..c02af0dcb8 100644
--- a/react/Badge/index.jsx
+++ b/react/Badge/index.jsx
@@ -114,12 +114,12 @@ const Badge = withStyles(customStyles)(
Badge.propTypes = {
anchorOrigin: PropTypes.shape({
- horizontal: PropTypes.oneOf('left', 'right'),
- vertical: PropTypes.oneOf('bottom', 'top')
+ horizontal: PropTypes.oneOf(['left', 'right']),
+ vertical: PropTypes.oneOf(['bottom', 'top'])
}),
- size: PropTypes.oneOf('small', 'medium', 'large'),
+ size: PropTypes.oneOf(['small', 'medium', 'large']),
showZero: PropTypes.bool,
- variant: PropTypes.oneOf('standard', 'dot')
+ variant: PropTypes.oneOf(['standard', 'dot'])
}
Badge.defaultProps = {
diff --git a/react/ContactsList/ContactsList.jsx b/react/ContactsList/ContactsList.jsx
index dcbaf8f0f6..625a478874 100644
--- a/react/ContactsList/ContactsList.jsx
+++ b/react/ContactsList/ContactsList.jsx
@@ -18,8 +18,8 @@ const ContactsList = props => {
{sortedHeaders.map(header => (
-
- {header}
+ {header}
{categorizedContacts[header].map(contact => (
-
{
useEventListener(document, 'resume', apps.fetch)
+ if (apps.fetchStatus === 'loading') {
+ return null
+ }
+
return (
{
_type: 'io.cozy.apps',
attributes: {
slug: 'contacts'
+ },
+ links: {
+ related: 'http://contacts.cozy.tools:8080/'
}
}
]
diff --git a/react/Viewer/TextViewer.spec.jsx b/react/Viewer/TextViewer.spec.jsx
index 18c032a7bf..c2b691bea3 100644
--- a/react/Viewer/TextViewer.spec.jsx
+++ b/react/Viewer/TextViewer.spec.jsx
@@ -3,8 +3,17 @@ import { shallow } from 'enzyme'
import { TextViewer, isMarkdown } from './TextViewer'
import { createMockClient } from 'cozy-client'
import renderer from 'react-test-renderer'
+
+const client = createMockClient({})
+
+const mockFetch = responseText => async () => ({
+ text: async () => responseText
+})
+
+client.stackClient.fetch = mockFetch('Text')
+
const props = {
- client: createMockClient({}),
+ client,
url: 'https://foo.mycozy.cloud',
file: {
_id: '1',
diff --git a/react/__snapshots__/examples.spec.jsx.snap b/react/__snapshots__/examples.spec.jsx.snap
index 6b307334ed..6f5783a22c 100644
--- a/react/__snapshots__/examples.spec.jsx.snap
+++ b/react/__snapshots__/examples.spec.jsx.snap
@@ -434,797 +434,797 @@ exports[`ContactsList should render examples: ContactsList 1`] = `
@@ -1237,797 +1237,797 @@ exports[`ContactsList should render examples: ContactsList 2`] = `
diff --git a/test/jestsetup.js b/test/jestsetup.js
index d9e0cc5c9b..8d91f62429 100644
--- a/test/jestsetup.js
+++ b/test/jestsetup.js
@@ -8,6 +8,8 @@ global.shallow = shallow
const isDeprecatedLifecycleWarning = (msg, componentName) => {
return (
+ msg &&
+ msg.includes &&
msg.includes('has been renamed, and is not recommended for use') &&
msg.includes(componentName)
)
@@ -45,7 +47,11 @@ const ignoredWarnings = {
},
ModalAriaLabel: {
reason: 'Dont know',
- matcher: msg => msg.includes('aria-label') && msg.includes('If your modal')
+ matcher: msg =>
+ msg &&
+ msg.includes &&
+ msg.includes('aria-label') &&
+ msg.includes('If your modal')
}
}