cozy-ui 113.7.1 → 113.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.nvmrc +1 -1
  2. package/CHANGELOG.md +15 -0
  3. package/assets/icons/ui/number.svg +1 -0
  4. package/jest.config.js +1 -2
  5. package/package.json +2 -8
  6. package/react/AppSections/components/AppsSection.spec.jsx +10 -19
  7. package/react/AppSections/index.spec.jsx +98 -77
  8. package/react/ContactsList/ContactRow.spec.js +28 -53
  9. package/react/DateMonthPicker/index.spec.jsx +17 -45
  10. package/react/Field/index.spec.js +28 -5
  11. package/react/Figure/Figure.spec.jsx +9 -4
  12. package/react/Figure/__snapshots__/Figure.spec.jsx.snap +289 -225
  13. package/react/FileInput/index.jsx +1 -0
  14. package/react/FileInput/index.spec.jsx +16 -38
  15. package/react/Icon/Readme.md +5 -1
  16. package/react/Icons/Number.jsx +16 -0
  17. package/react/Popup/index.spec.jsx +90 -41
  18. package/react/QualificationIconStack/Readme.md +14 -0
  19. package/react/QualificationIconStack/index.jsx +132 -0
  20. package/react/deprecated/ViewStack/example.jsx +1 -1
  21. package/react/hooks/useClientErrors.spec.jsx +16 -24
  22. package/react/providers/I18n/index.spec.jsx +13 -5
  23. package/react/providers/I18n/withLocales.spec.jsx +4 -4
  24. package/transpiled/react/FileInput/index.js +2 -1
  25. package/transpiled/react/Icon/icons-sprite.js +1 -1
  26. package/transpiled/react/Icons/Number.js +15 -0
  27. package/transpiled/react/QualificationIconStack/index.js +132 -0
  28. package/transpiled/react/deprecated/ViewStack/example.js +1 -1
  29. package/react/AppSections/__snapshots__/index.spec.jsx.snap +0 -1843
  30. package/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap +0 -41
  31. package/react/ContactsList/__snapshots__/ContactRow.spec.js.snap +0 -69
  32. package/react/FileInput/__snapshots__/index.spec.jsx.snap +0 -86
  33. package/react/Input/__snapshots__/index.spec.jsx.snap +0 -11
  34. package/react/Input/index.spec.jsx +0 -12
  35. package/react/__snapshots__/examples.spec.jsx.snap +0 -3720
  36. package/react/deprecated/ActionMenu/__snapshots__/index.spec.jsx.snap +0 -157
  37. package/react/deprecated/ActionMenu/index.spec.jsx +0 -115
  38. package/react/deprecated/Alerter/__snapshots__/alerter.spec.js.snap +0 -88
  39. package/react/deprecated/Alerter/alerter.spec.js +0 -78
  40. package/react/deprecated/InfosCarrousel/index.spec.jsx +0 -71
  41. package/react/deprecated/Modal/index.spec.jsx +0 -70
  42. package/react/deprecated/ViewStack/index.spec.jsx +0 -64
  43. package/react/examples.spec.jsx +0 -67
@@ -1,157 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`ActionMenu should render as expected 1`] = `
4
- <div>
5
- <div
6
- class="styles__media___cSJMp styles__media--top___K9w0I styles__c-actionmenu-item___gODqd"
7
- >
8
- <div
9
- class="styles__img___3SHpG u-mh-1"
10
- >
11
- <svg
12
- class="styles__icon___23x3R"
13
- height="16"
14
- viewBox="0 0 16 16"
15
- width="16"
16
- >
17
- <defs>
18
- <path
19
- d="M1 1c0-.552.446-1 .998-1H10v5h5v10.004a1 1 0 01-1.007.996H2.007A1.002 1.002 0 011 15V1zm10 3V0l4 4h-4z"
20
- id="file_svg__a"
21
- />
22
- </defs>
23
- <use
24
- fill-rule="evenodd"
25
- xlink:href="#file_svg__a"
26
- />
27
- </svg>
28
- </div>
29
- <div
30
- class="styles__bd___1Uv-F u-mr-1 u-stack-xs"
31
- >
32
- Item 1 with onclick action
33
- </div>
34
- <div
35
- class="styles__img___3SHpG u-mr-1"
36
- >
37
- <svg
38
- class="styles__icon___23x3R"
39
- height="16"
40
- style="fill: var(--errorColor);"
41
- viewBox="0 0 16 16"
42
- width="16"
43
- >
44
- <path
45
- d="M7.022 1.736c.543-.959 1.428-.95 1.966 0l6.532 11.529c.543.958.094 1.735-1.016 1.735h-13C.399 15-.051 14.215.487 13.265l6.535-11.53zM7.004 13c0-.552.443-1 1-1 .552 0 1 .444 1 1 0 .553-.444 1-1 1-.553 0-1-.444-1-1zm0-7.997a.999.999 0 011-1.003c.552 0 1 .438 1 1.003v4.994a.999.999 0 01-1 1.003c-.553 0-1-.438-1-1.003V5.003z"
46
- fill-rule="evenodd"
47
- />
48
- </svg>
49
- </div>
50
- </div>
51
- <div
52
- class="styles__media___cSJMp styles__media--top___K9w0I styles__c-actionmenu-item___gODqd"
53
- >
54
- <div
55
- class="styles__img___3SHpG u-mh-1"
56
- >
57
- <svg
58
- class="styles__icon___23x3R"
59
- height="16"
60
- viewBox="0 0 16 16"
61
- width="16"
62
- >
63
- <defs>
64
- <path
65
- d="M1 1c0-.552.446-1 .998-1H10v5h5v10.004a1 1 0 01-1.007.996H2.007A1.002 1.002 0 011 15V1zm10 3V0l4 4h-4z"
66
- id="file_svg__a"
67
- />
68
- </defs>
69
- <use
70
- fill-rule="evenodd"
71
- xlink:href="#file_svg__a"
72
- />
73
- </svg>
74
- </div>
75
- <div
76
- class="styles__bd___1Uv-F u-mr-1 u-stack-xs"
77
- >
78
- Item 2 with dialog action
79
- </div>
80
- </div>
81
- <div
82
- class="styles__media___cSJMp styles__media--top___K9w0I styles__c-actionmenu-item___gODqd"
83
- >
84
- <div
85
- class="styles__img___3SHpG u-mh-1"
86
- >
87
- <label
88
- class="styles__c-input-radio___XJQt1 styles__c-actionmenu-radio___Km9uj"
89
- >
90
- <input
91
- type="radio"
92
- value=""
93
- />
94
- <span />
95
- </label>
96
- </div>
97
- <div
98
- class="styles__bd___1Uv-F u-mr-1 u-stack-xs"
99
- >
100
- Item 3
101
- </div>
102
- </div>
103
- <div
104
- class="styles__media___cSJMp styles__media--top___K9w0I styles__c-actionmenu-item___gODqd"
105
- >
106
- <div
107
- class="styles__img___3SHpG u-mh-1"
108
- >
109
- <svg
110
- class="styles__icon___23x3R"
111
- height="16"
112
- viewBox="0 0 16 16"
113
- width="16"
114
- >
115
- <defs>
116
- <path
117
- d="M1 1c0-.552.446-1 .998-1H10v5h5v10.004a1 1 0 01-1.007.996H2.007A1.002 1.002 0 011 15V1zm10 3V0l4 4h-4z"
118
- id="file_svg__a"
119
- />
120
- </defs>
121
- <use
122
- fill-rule="evenodd"
123
- xlink:href="#file_svg__a"
124
- />
125
- </svg>
126
- </div>
127
- <div
128
- class="styles__bd___1Uv-F u-mr-1 u-stack-xs"
129
- >
130
- <p
131
- class="MuiTypography-root MuiTypography-body1 MuiTypography-colorTextPrimary MuiTypography-gutterBottom"
132
- >
133
- Item 4
134
- </p>
135
- <span
136
- class="MuiTypography-root MuiTypography-caption MuiTypography-colorTextSecondary"
137
- >
138
- Descriptive text to elaborate on what item 3 does.
139
- </span>
140
- </div>
141
- </div>
142
- </div>
143
- `;
144
-
145
- exports[`ActionMenu should support null children 1`] = `
146
- <div
147
- className="styles__c-actionmenu___22Fp1 styles__c-actionmenu--inline___1SXZa"
148
- onClick={[Function]}
149
- onTouchEnd={[Function]}
150
- >
151
- <ActionMenuItem
152
- contentSpacing="xs"
153
- >
154
- Item 1
155
- </ActionMenuItem>
156
- </div>
157
- `;
@@ -1,115 +0,0 @@
1
- import { render } from '@testing-library/react'
2
- import { mount } from 'enzyme'
3
- import React from 'react'
4
- import { act } from 'react-dom/test-utils'
5
-
6
- import ActionMenu, { ActionMenuItem, ActionMenuRadio } from '.'
7
- import Icon from '../../Icon'
8
- import FileIcon from '../../Icons/File'
9
- import WarningIcon from '../../Icons/Warning'
10
- import { fixPopperTesting } from '../../Popper/testing'
11
- import Typography from '../../Typography'
12
- import { BreakpointsProvider } from '../../providers/Breakpoints'
13
-
14
- xdescribe('ActionMenu', () => {
15
- fixPopperTesting()
16
-
17
- // The update-not-wrapping-in-act warning is disabled for ActionMenuWrapper since
18
- // we have not found how to remove the "update" happening when mounting the
19
- // ActionMenu.
20
- let originalConsoleError = console.error
21
-
22
- beforeEach(() => {
23
- // eslint-disable-next-line no-console
24
- console.error = function (msg, arg) {
25
- if (
26
- msg.includes('An update to %s inside a test was not wrapped in act') &&
27
- arg == 'ActionMenuWrapper'
28
- ) {
29
- return
30
- } else {
31
- return originalConsoleError.apply(this, arguments)
32
- }
33
- }
34
- })
35
-
36
- afterEach(() => {
37
- // eslint-disable-next-line no-console
38
- console.error = originalConsoleError
39
- })
40
-
41
- it('should support null children', async () => {
42
- const comp = mount(
43
- <BreakpointsProvider>
44
- <ActionMenu onClose={jest.fn()}>
45
- <ActionMenuItem>Item 1</ActionMenuItem>
46
- {null}
47
- </ActionMenu>
48
- </BreakpointsProvider>
49
- )
50
- // Remove an update was not wrapped in act() warning
51
- await act(async () => {})
52
- expect(comp.find(ActionMenuItem).parent().getElement()).toMatchSnapshot()
53
- })
54
-
55
- it('should support auto-closing the menu', async () => {
56
- const closeMenu = jest.fn()
57
- const menuAction1 = jest.fn()
58
- const menuAction2 = jest.fn()
59
- const menuActionStoppingPropagation = e => {
60
- e.stopPropagation()
61
- menuAction2()
62
- }
63
-
64
- const comp = mount(
65
- <BreakpointsProvider>
66
- <ActionMenu onClose={closeMenu} autoclose>
67
- <ActionMenuItem onClick={menuAction1}>Item 1</ActionMenuItem>
68
- <ActionMenuItem onClick={menuActionStoppingPropagation}>
69
- Item 2
70
- </ActionMenuItem>
71
- </ActionMenu>
72
- </BreakpointsProvider>
73
- )
74
-
75
- await act(async () => {
76
- comp.find(ActionMenuItem).at(1).simulate('click')
77
- })
78
- expect(menuAction2).toHaveBeenCalled()
79
- expect(closeMenu).not.toHaveBeenCalled()
80
-
81
- act(() => {
82
- comp.find(ActionMenuItem).at(0).simulate('click')
83
- })
84
- expect(menuAction1).toHaveBeenCalled()
85
- expect(closeMenu).toHaveBeenCalled()
86
- })
87
-
88
- it('should render as expected', async () => {
89
- const { container } = render(
90
- <BreakpointsProvider>
91
- <ActionMenuItem
92
- left={<Icon icon={FileIcon} />}
93
- right={<Icon icon={WarningIcon} color="var(--errorColor)" />}
94
- onClick={() => alert('click')}
95
- >
96
- Item 1 with onclick action
97
- </ActionMenuItem>
98
- <ActionMenuItem left={<Icon icon={FileIcon} />}>
99
- Item 2 with dialog action
100
- </ActionMenuItem>
101
- <ActionMenuItem left={<ActionMenuRadio />}>Item 3</ActionMenuItem>
102
- <ActionMenuItem left={<Icon icon={FileIcon} />}>
103
- <Typography variant="body1" gutterBottom>
104
- Item 4
105
- </Typography>
106
- <Typography variant="caption" color="textSecondary">
107
- Descriptive text to elaborate on what item 3 does.
108
- </Typography>
109
- </ActionMenuItem>
110
- </BreakpointsProvider>
111
- )
112
-
113
- expect(container).toMatchSnapshot()
114
- })
115
- })
@@ -1,88 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Alerter component handles dismiss provided to buttonAction 1`] = `
4
- <div
5
- className="styles__c-alert___dJvZ8 styles__c-alert--hidden___2HD9e"
6
- role="alert"
7
- >
8
- <div
9
- className="styles__c-alert-wrapper___1VWFK styles__c-alert--info___2EDwe"
10
- >
11
- <p>
12
- Test alert with button
13
- </p>
14
- <DefaultButton
15
- className="styles__c-btn--alert-info___1xAkg"
16
- label="BTN"
17
- onClick={[Function]}
18
- size="tiny"
19
- />
20
- </div>
21
- </div>
22
- `;
23
-
24
- exports[`Alerter component renders button if buttonText provided 1`] = `
25
- <div
26
- className="styles__c-alert___dJvZ8 styles__c-alert--hidden___2HD9e"
27
- role="alert"
28
- >
29
- <div
30
- className="styles__c-alert-wrapper___1VWFK styles__c-alert--info___2EDwe"
31
- >
32
- <p>
33
- Test alert with button
34
- </p>
35
- <DefaultButton
36
- className="styles__c-btn--alert-info___1xAkg"
37
- label="BTN"
38
- onClick={[Function]}
39
- size="tiny"
40
- />
41
- </div>
42
- </div>
43
- `;
44
-
45
- exports[`Alerter component renders correctly an error alert 1`] = `
46
- <div
47
- className="styles__c-alert___dJvZ8 styles__c-alert--hidden___2HD9e"
48
- role="alert"
49
- >
50
- <div
51
- className="styles__c-alert-wrapper___1VWFK styles__c-alert--error___g5tIs"
52
- >
53
- <p>
54
- Test error alert
55
- </p>
56
- </div>
57
- </div>
58
- `;
59
-
60
- exports[`Alerter component renders correctly an info alert 1`] = `
61
- <div
62
- className="styles__c-alert___dJvZ8 styles__c-alert--hidden___2HD9e"
63
- role="alert"
64
- >
65
- <div
66
- className="styles__c-alert-wrapper___1VWFK styles__c-alert--info___2EDwe"
67
- >
68
- <p>
69
- Test info alert
70
- </p>
71
- </div>
72
- </div>
73
- `;
74
-
75
- exports[`Alerter component renders correctly an success alert 1`] = `
76
- <div
77
- className="styles__c-alert___dJvZ8 styles__c-alert--hidden___2HD9e"
78
- role="alert"
79
- >
80
- <div
81
- className="styles__c-alert-wrapper___1VWFK styles__c-alert--success___2DGDO"
82
- >
83
- <p>
84
- Test success alert
85
- </p>
86
- </div>
87
- </div>
88
- `;
@@ -1,78 +0,0 @@
1
- 'use strict'
2
- /* eslint-env jest */
3
-
4
- import { shallow } from 'enzyme'
5
- import React from 'react'
6
-
7
- import Alerter from '.'
8
- import Alert from './Alert'
9
- import Button from '../Button'
10
-
11
- describe('Alerter component', () => {
12
- beforeEach(() => {
13
- Alerter.reset()
14
- })
15
- //
16
- ;['info', 'success', 'error'].forEach(type => {
17
- it(`renders correctly an ${type} alert`, () => {
18
- const wrapper = shallow(<Alerter />)
19
- Alerter[type](`Test ${type} alert`)
20
- expect(wrapper.find(Alert).dive().getElement()).toMatchSnapshot()
21
- })
22
- })
23
-
24
- it('should not render too much alerts', () => {
25
- const wrapper = shallow(<Alerter />)
26
- Alerter.info(`Test 1`)
27
- Alerter.info(`Test 2`)
28
- Alerter.info(`Test 3`)
29
- expect(wrapper.find(Alert).length).toBe(3)
30
- })
31
-
32
- it('renders button if buttonText provided', () => {
33
- const wrapper = shallow(<Alerter />)
34
- Alerter.info(`Test alert with button`, {
35
- buttonText: 'BTN'
36
- })
37
- expect(wrapper.find(Alert).dive().getElement()).toMatchSnapshot()
38
- })
39
-
40
- it('handles dismiss provided to buttonAction', () => {
41
- const alerterWrapper = shallow(<Alerter />)
42
- Alerter.info(`Test alert with button`, {
43
- buttonText: 'BTN',
44
- buttonAction: dismiss => {
45
- console.log('DISMISS')
46
- dismiss()
47
- },
48
- duration: 20000
49
- })
50
- const alertWrapper = alerterWrapper.find(Alert)
51
- const alert = alertWrapper.dive()
52
- expect(alert.getElement()).toMatchSnapshot()
53
- alert.instance().base = document.createElement('div')
54
- // we have to wait the same delay as in the Alerter didMount
55
- setTimeout(() => {
56
- expect(alert.state('hidden')).toBe(false)
57
- alert.children().find(Button).simulate('click')
58
- expect(alert.state('hidden')).toBe(true)
59
- }, 20)
60
- })
61
-
62
- it('handles programmatic removal', () => {
63
- const wrapper = shallow(<Alerter />)
64
- const notif = Alerter.info(`Test alert with button`, {
65
- duration: 20000
66
- })
67
- Alerter.info(`Test another alert`, {
68
- duration: 20000
69
- })
70
- expect(wrapper.find(Alert).length).toBe(2)
71
- Alerter.removeNotification(notif)
72
- expect(wrapper.find(Alert).length).toBe(1)
73
-
74
- // Nothing should happen if we try to remove a non existing notification
75
- Alerter.removeNotification(notif)
76
- expect(wrapper.find(Alert).length).toBe(1)
77
- })
78
- })
@@ -1,71 +0,0 @@
1
- import React from 'react'
2
- import { act } from 'react-dom/test-utils'
3
- import SwipeableViews from 'react-swipeable-views'
4
-
5
- import InfosCarrousel from '.'
6
- import IconButton from '../../IconButton'
7
- import Typography from '../../Typography'
8
- import Button from '../Button'
9
- import Infos from '../Infos'
10
-
11
- // This is necessary for tests to be predictable
12
- const swipeableProps = { disableLazyLoading: true }
13
-
14
- const Example = ({ numberOfChildren = 2 }) => (
15
- <div className="u-stack-m">
16
- <InfosCarrousel theme="danger" swipeableProps={swipeableProps}>
17
- {[...new Array(numberOfChildren)].map((child, index) => (
18
- <Infos
19
- key={index}
20
- description={
21
- <>
22
- <Typography variant="h5">News {index}</Typography>
23
- <Typography variant="body1">Breaking news {index}</Typography>
24
- </>
25
- }
26
- action={<Button theme="secondary" label="A CTA button" />}
27
- />
28
- ))}
29
- </InfosCarrousel>
30
- </div>
31
- )
32
-
33
- const getArrowsDisabledProps = root =>
34
- root
35
- .find(IconButton)
36
- .map(node => node.props())
37
- .map(x => x.disabled)
38
-
39
- const simulateSwipeToSlideIndex = (root, slideIndex) => {
40
- act(() => {
41
- root.find(SwipeableViews).props().onChangeIndex(slideIndex)
42
- })
43
- root.update()
44
- }
45
-
46
- describe('InfosCarrousel', () => {
47
- const setup = () => {
48
- const root = mount(<Example />)
49
- return { root }
50
- }
51
-
52
- it('should update arrows after swipe', () => {
53
- const { root } = setup()
54
- expect(getArrowsDisabledProps(root)).toEqual([true, false])
55
- simulateSwipeToSlideIndex(root, 1)
56
- expect(getArrowsDisabledProps(root)).toEqual([false, true])
57
- simulateSwipeToSlideIndex(root, 0)
58
- expect(getArrowsDisabledProps(root)).toEqual([true, false])
59
- })
60
-
61
- it('should change index when a child is removed', () => {
62
- const root = mount(<Example numberOfChildren={3} />)
63
- expect(root.find(SwipeableViews).prop('index')).toEqual(0)
64
- simulateSwipeToSlideIndex(root, 2)
65
- expect(root.find(SwipeableViews).prop('index')).toEqual(2)
66
- root.setProps({ numberOfChildren: 2 })
67
- root.update()
68
- expect(root.find(Infos).length).toBe(2)
69
- expect(root.find(SwipeableViews).prop('index')).toEqual(1)
70
- })
71
- })
@@ -1,70 +0,0 @@
1
- import { mount } from 'enzyme'
2
- import React, { useState } from 'react'
3
- import { act } from 'react-dom/test-utils'
4
-
5
- import Modal, { BODY_CLASS } from '.'
6
- import { BreakpointsProvider } from '../../providers/Breakpoints'
7
-
8
- describe('Modal', () => {
9
- const Example = () => {
10
- const [showModal, setShowModal] = useState(false)
11
- const [showModal2, setShowModal2] = useState(false)
12
- return (
13
- <BreakpointsProvider>
14
- {showModal ? <Modal title="example 1">1</Modal> : null}
15
- {showModal2 ? <Modal title="example 2">2</Modal> : null}
16
- <button onClick={() => setShowModal(true)} />
17
- <button onClick={() => setShowModal2(true)} />
18
- <button onClick={() => setShowModal2(false)} />
19
- <button onClick={() => setShowModal(false)} />
20
- </BreakpointsProvider>
21
- )
22
- }
23
-
24
- const clickNthButton = (root, n) =>
25
- root.find('button').at(n).props().onClick()
26
-
27
- const mountFirstModal = root => clickNthButton(root, 0)
28
- const mountSecondModal = root => clickNthButton(root, 1)
29
- const unmountSecondModal = root => clickNthButton(root, 2)
30
- const unmountFirstModal = root => clickNthButton(root, 3)
31
-
32
- const hasModalBodyClass = () => document.body.classList.contains(BODY_CLASS)
33
-
34
- afterEach(() => {
35
- document.body.classList.remove(BODY_CLASS)
36
- })
37
-
38
- it('should apply a class to the body when mounted', () => {
39
- const root = mount(<Example />)
40
- expect(hasModalBodyClass()).toBe(false)
41
- act(() => {
42
- mountFirstModal(root)
43
- })
44
- expect(hasModalBodyClass()).toBe(true)
45
- act(() => {
46
- unmountFirstModal(root)
47
- })
48
- expect(hasModalBodyClass()).toBe(false)
49
- })
50
-
51
- it('should not remove the class if two modals were mounted and the second one is removed', () => {
52
- const root = mount(<Example />)
53
- expect(hasModalBodyClass()).toBe(false)
54
- act(() => {
55
- mountFirstModal(root)
56
- })
57
- expect(hasModalBodyClass()).toBe(true)
58
- act(() => {
59
- mountSecondModal(root)
60
- })
61
- act(() => {
62
- unmountSecondModal(root)
63
- })
64
- expect(hasModalBodyClass()).toBe(true)
65
- act(() => {
66
- unmountFirstModal(root)
67
- })
68
- expect(hasModalBodyClass()).toBe(false)
69
- })
70
- })
@@ -1,64 +0,0 @@
1
- import { mount } from 'enzyme'
2
- import React from 'react'
3
- import { act } from 'react-dom/test-utils'
4
- import SwipeableViews from 'react-swipeable-views'
5
-
6
- import ViewStack from '.'
7
- import { Slide } from './example'
8
- import Button from '../Button'
9
-
10
- const findButtonWithLabel = (root, label) =>
11
- root.findWhere(n => n.type() == Button && n.props().label === label)
12
-
13
- describe('ViewStack', () => {
14
- beforeEach(() => {
15
- const originalError = console.error.bind(console)
16
-
17
- // Ignore act's warning, since act does not support async logic and we have
18
- // a sleep when popping to wait for the animation
19
- jest.spyOn(console, 'error').mockImplementation(function (message) {
20
- if (
21
- !message.includes(
22
- 'An update to %s inside a test was not wrapped in act'
23
- )
24
- ) {
25
- originalError.apply(this, arguments)
26
- }
27
- })
28
- })
29
-
30
- afterEach(() => {
31
- jest.restoreAllMocks()
32
- })
33
-
34
- it('should push / pop views', async () => {
35
- const root = mount(
36
- <ViewStack>
37
- <Slide number={1} />
38
- </ViewStack>
39
- )
40
- expect(root.find(Slide).props().number).toBe(1)
41
- act(() => {
42
- findButtonWithLabel(root, 'stack').props().onClick()
43
- })
44
- root.update()
45
-
46
- const swiperProps = root.find(SwipeableViews).props()
47
- expect(swiperProps.children.length).toBe(2)
48
- expect(swiperProps.index).toBe(1)
49
-
50
- let prom
51
- act(() => {
52
- prom = findButtonWithLabel(root, 'pop').props().onClick()
53
- })
54
- root.update()
55
- const swiperProps2 = root.find(SwipeableViews).props()
56
- expect(swiperProps2.index).toBe(0)
57
- expect(swiperProps2.children.length).toBe(2) // waiting for animation
58
-
59
- await prom
60
- root.update()
61
- const swiperProps3 = root.find(SwipeableViews).props()
62
- expect(swiperProps3.children.length).toBe(1)
63
- })
64
- })