cozy-ui 113.8.0 → 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 (37) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/jest.config.js +1 -2
  3. package/package.json +1 -7
  4. package/react/AppSections/components/AppsSection.spec.jsx +10 -19
  5. package/react/AppSections/index.spec.jsx +98 -77
  6. package/react/ContactsList/ContactRow.spec.js +28 -53
  7. package/react/DateMonthPicker/index.spec.jsx +17 -45
  8. package/react/Field/index.spec.js +28 -5
  9. package/react/Figure/Figure.spec.jsx +9 -4
  10. package/react/Figure/__snapshots__/Figure.spec.jsx.snap +289 -225
  11. package/react/FileInput/index.jsx +1 -0
  12. package/react/FileInput/index.spec.jsx +16 -38
  13. package/react/Popup/index.spec.jsx +90 -41
  14. package/react/QualificationIconStack/Readme.md +4 -1
  15. package/react/QualificationIconStack/index.jsx +28 -7
  16. package/react/deprecated/ViewStack/example.jsx +1 -1
  17. package/react/hooks/useClientErrors.spec.jsx +16 -24
  18. package/react/providers/I18n/index.spec.jsx +13 -5
  19. package/react/providers/I18n/withLocales.spec.jsx +4 -4
  20. package/transpiled/react/FileInput/index.js +2 -1
  21. package/transpiled/react/QualificationIconStack/index.js +26 -6
  22. package/transpiled/react/deprecated/ViewStack/example.js +1 -1
  23. package/react/AppSections/__snapshots__/index.spec.jsx.snap +0 -1843
  24. package/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap +0 -41
  25. package/react/ContactsList/__snapshots__/ContactRow.spec.js.snap +0 -69
  26. package/react/FileInput/__snapshots__/index.spec.jsx.snap +0 -86
  27. package/react/Input/__snapshots__/index.spec.jsx.snap +0 -11
  28. package/react/Input/index.spec.jsx +0 -12
  29. package/react/__snapshots__/examples.spec.jsx.snap +0 -3720
  30. package/react/deprecated/ActionMenu/__snapshots__/index.spec.jsx.snap +0 -157
  31. package/react/deprecated/ActionMenu/index.spec.jsx +0 -115
  32. package/react/deprecated/Alerter/__snapshots__/alerter.spec.js.snap +0 -88
  33. package/react/deprecated/Alerter/alerter.spec.js +0 -78
  34. package/react/deprecated/InfosCarrousel/index.spec.jsx +0 -71
  35. package/react/deprecated/Modal/index.spec.jsx +0 -70
  36. package/react/deprecated/ViewStack/index.spec.jsx +0 -64
  37. package/react/examples.spec.jsx +0 -67
@@ -1,3 +1,4 @@
1
+ import { fireEvent, render, screen } from '@testing-library/react'
1
2
  import uniqueId from 'lodash/uniqueId'
2
3
  import React from 'react'
3
4
 
@@ -20,66 +21,43 @@ describe('FileInput component', () => {
20
21
  })
21
22
 
22
23
  it('should render a file selector', () => {
23
- const component = shallow(
24
+ render(
24
25
  <FileInput onChange={onChangeSpy}>
25
26
  <span>Click me</span>
26
27
  </FileInput>
27
- ).getElement()
28
- expect(component).toMatchSnapshot()
29
- })
30
-
31
- it('should render a default file selector', () => {
32
- const component = shallow(
33
- <FileInput hidden={false} onChange={onChangeSpy} />
34
- ).getElement()
35
- expect(component).toMatchSnapshot()
36
- })
28
+ )
37
29
 
38
- it('should render a disabled file selector', () => {
39
- const component = shallow(
40
- <FileInput disabled onChange={onChangeSpy}>
41
- <span>Click me</span>
42
- </FileInput>
43
- ).getElement()
44
- expect(component).toMatchSnapshot()
45
- })
30
+ const button = screen.getByText('Click me')
46
31
 
47
- it('should pass props to the input', () => {
48
- const component = shallow(
49
- <FileInput accept="image/*" onChange={onChangeSpy}>
50
- <span>Click me</span>
51
- </FileInput>
52
- ).getElement()
53
- expect(component).toMatchSnapshot()
32
+ expect(button).toBeInTheDocument()
33
+ expect(screen.getByTestId('file-input')).toBeInTheDocument()
54
34
  })
55
35
 
56
36
  it('should process selected file on change', () => {
57
37
  const filelist = [pic1]
58
- const component = shallow(
38
+ render(
59
39
  <FileInput accept="image/*" onChange={onChangeSpy}>
60
40
  <span>Click me</span>
61
41
  </FileInput>
62
42
  )
63
- component.find('input').simulate('change', {
64
- target: {
65
- files: filelist
66
- }
67
- })
43
+
44
+ const input = screen.getByTestId('file-input')
45
+ fireEvent.change(input, { target: { files: filelist } })
46
+
68
47
  expect(onChangeSpy).toHaveBeenCalledWith(pic1)
69
48
  })
70
49
 
71
50
  it('should process selected files on change if it is multiple', () => {
72
51
  const filelist = [pic1, pic2]
73
- const component = shallow(
52
+ render(
74
53
  <FileInput accept="image/*" multiple onChange={onChangeSpy}>
75
54
  <span>Click me</span>
76
55
  </FileInput>
77
56
  )
78
- component.find('input').simulate('change', {
79
- target: {
80
- files: filelist
81
- }
82
- })
57
+
58
+ const input = screen.getByTestId('file-input')
59
+ fireEvent.change(input, { target: { files: filelist } })
60
+
83
61
  expect(onChangeSpy).toHaveBeenCalledWith([pic1, pic2])
84
62
  })
85
63
  })
@@ -1,4 +1,4 @@
1
- import { shallow } from 'enzyme'
1
+ import { render, fireEvent } from '@testing-library/react'
2
2
  import React from 'react'
3
3
 
4
4
  import { isMobileApp } from 'cozy-device-helper'
@@ -17,35 +17,56 @@ const props = {
17
17
  height: '200'
18
18
  }
19
19
 
20
- const popupMock = {}
21
- class MessageEventMock {
22
- constructor(options = {}) {
23
- this.source = options.source || popupMock
20
+ class MessageEventMock extends Event {
21
+ constructor(options = {}, mock) {
22
+ super('message', options)
23
+ this.source = options.source || mock
24
+ }
25
+ }
26
+
27
+ class LoadStartEventMock extends Event {
28
+ constructor(url) {
29
+ super('loadstart')
30
+ this.url = url
31
+ }
32
+ }
33
+
34
+ class ExitEventMock extends Event {
35
+ constructor() {
36
+ super('exit')
24
37
  }
25
38
  }
26
39
 
27
40
  describe('Popup', () => {
28
- beforeAll(() => {
29
- jest.useFakeTimers()
41
+ const setup = ({ mockAddEventListener = true }) => {
42
+ const popupMock = new EventTarget()
43
+
44
+ isMobileApp.mockReturnValue(false)
30
45
 
31
46
  jest.spyOn(global, 'open').mockReturnValue(popupMock)
32
47
  jest.spyOn(global, 'addEventListener')
33
- })
34
48
 
35
- afterAll(() => {
36
- global.open.mockRestore()
37
- global.addEventListener.mockRestore()
38
- })
49
+ if (mockAddEventListener) {
50
+ popupMock.addEventListener = jest.fn()
51
+ }
39
52
 
40
- beforeEach(() => {
41
- isMobileApp.mockReturnValue(false)
42
- popupMock.addEventListener = jest.fn()
43
53
  popupMock.close = jest.fn()
44
54
  popupMock.focus = jest.fn()
45
55
  popupMock.closed = false
46
56
  props.onClose = jest.fn()
47
57
  props.onMessage = jest.fn()
48
58
  props.onMobileUrlChange = jest.fn()
59
+
60
+ return popupMock
61
+ }
62
+
63
+ beforeAll(() => {
64
+ jest.useFakeTimers()
65
+ })
66
+
67
+ afterAll(() => {
68
+ global.open.mockRestore()
69
+ global.addEventListener.mockRestore()
49
70
  })
50
71
 
51
72
  afterEach(() => {
@@ -54,7 +75,10 @@ describe('Popup', () => {
54
75
  })
55
76
 
56
77
  it('should open new window', () => {
57
- shallow(<Popup {...props} />)
78
+ const popupMock = setup({})
79
+
80
+ render(<Popup {...props} />)
81
+
58
82
  expect(global.open).toHaveBeenCalledWith(
59
83
  props.initialUrl,
60
84
  props.title,
@@ -64,66 +88,91 @@ describe('Popup', () => {
64
88
  })
65
89
 
66
90
  it('should subscribe to message events', () => {
67
- const wrapper = shallow(<Popup {...props} />)
91
+ setup({})
92
+
93
+ render(<Popup {...props} />)
94
+
68
95
  expect(global.addEventListener).toHaveBeenCalledWith(
69
96
  'message',
70
- wrapper.instance().handleMessage
97
+ expect.any(Function)
71
98
  )
72
99
  })
73
100
 
74
101
  it('should subcribe to mobile events', () => {
102
+ const popupMock = setup({})
75
103
  isMobileApp.mockReturnValue(true)
76
- const wrapper = shallow(<Popup {...props} />)
104
+
105
+ render(<Popup {...props} />)
106
+
77
107
  expect(popupMock.addEventListener).toHaveBeenCalledWith(
78
108
  'loadstart',
79
- wrapper.instance().handleLoadStart
109
+ expect.any(Function)
80
110
  )
81
111
  expect(popupMock.addEventListener).toHaveBeenCalledWith(
82
112
  'exit',
83
- wrapper.instance().handleClose
113
+ expect.any(Function)
84
114
  )
85
115
  })
86
116
 
87
- describe('monitorClosing', () => {
88
- it('should detect closing', () => {
89
- const wrapper = shallow(<Popup {...props} />)
90
- jest.spyOn(wrapper.instance(), 'handleClose')
91
- popupMock.closed = true
92
- jest.runAllTimers()
93
- expect(wrapper.instance().handleClose).toHaveBeenCalled()
94
- })
95
- })
96
-
97
117
  describe('handleClose', () => {
98
118
  it('should call onClose', () => {
99
- const wrapper = shallow(<Popup {...props} />)
100
- wrapper.instance().handleClose()
119
+ const popupMock = setup({
120
+ mockAddEventListener: false
121
+ })
122
+ isMobileApp.mockReturnValue(true)
123
+
124
+ render(<Popup {...props} />)
125
+
126
+ const messageEvent = new ExitEventMock()
127
+ fireEvent(popupMock, messageEvent)
128
+
101
129
  expect(props.onClose).toHaveBeenCalled()
102
130
  })
103
131
  })
104
132
 
105
133
  describe('handleMessage', () => {
106
134
  it('should call onMessage', () => {
107
- const wrapper = shallow(<Popup {...props} />)
108
- const messageEvent = new MessageEventMock()
109
- wrapper.instance().handleMessage(messageEvent)
135
+ const popupMock = setup({
136
+ mockAddEventListener: false
137
+ })
138
+ isMobileApp.mockReturnValue(true)
139
+
140
+ render(<Popup {...props} />)
141
+
142
+ const messageEvent = new MessageEventMock({}, popupMock)
143
+ fireEvent(window, messageEvent)
144
+
110
145
  expect(props.onMessage).toHaveBeenCalledWith(messageEvent)
111
146
  })
112
147
 
113
148
  it('should ignore messageEvent from another window ', () => {
114
- const wrapper = shallow(<Popup {...props} />)
149
+ setup({
150
+ mockAddEventListener: false
151
+ })
152
+ isMobileApp.mockReturnValue(true)
153
+
154
+ render(<Popup {...props} />)
155
+
115
156
  const messageEvent = new MessageEventMock({ source: {} })
116
- wrapper.instance().handleMessage(messageEvent)
157
+ fireEvent(window, messageEvent)
158
+
117
159
  expect(props.onMessage).not.toHaveBeenCalled()
118
160
  })
119
161
  })
120
162
 
121
163
  describe('handleLoadStart', () => {
122
164
  it('should call onMobileUrlChange', () => {
123
- const wrapper = shallow(<Popup {...props} />)
165
+ const popupMock = setup({
166
+ mockAddEventListener: false
167
+ })
168
+ isMobileApp.mockReturnValue(true)
169
+
170
+ render(<Popup {...props} />)
171
+
124
172
  const url = 'https://cozy.io'
125
- const urlEvent = { url }
126
- wrapper.instance().handleLoadStart(urlEvent)
173
+ const messageEvent = new LoadStartEventMock(url)
174
+ fireEvent(popupMock, messageEvent)
175
+
127
176
  expect(props.onMobileUrlChange).toHaveBeenCalledWith(expect.any(URL))
128
177
  expect(props.onMobileUrlChange).toHaveBeenCalledWith(new URL(url))
129
178
  })
@@ -4,8 +4,11 @@ import QualificationIconStack from 'cozy-ui/transpiled/react/QualificationIconSt
4
4
  ;
5
5
 
6
6
  <>
7
+ <QualificationIconStack className="u-mr-1" />
7
8
  <QualificationIconStack className="u-mr-1" qualification="isp_invoice" />
8
9
  <QualificationIconStack className="u-mr-1" qualification="phone_invoice" />
9
- <QualificationIconStack qualification="family_record_book" />
10
+ <QualificationIconStack className="u-mr-1" qualification="family_record_book" />
11
+ <QualificationIconStack className="u-mr-1" theme="identity" />
12
+ <QualificationIconStack theme="transport" />
10
13
  </>
11
14
  ```
@@ -10,7 +10,9 @@ import BankCheckIcon from '../Icons/BankCheck'
10
10
  import BenefitIcon from '../Icons/Benefit'
11
11
  import BillIcon from '../Icons/Bill'
12
12
  import CarIcon from '../Icons/Car'
13
+ import ChessIcon from '../Icons/Chess'
13
14
  import ChildIcon from '../Icons/Child'
15
+ import DotsIcon from '../Icons/Dots'
14
16
  import EmailIcon from '../Icons/Email'
15
17
  import EuroIcon from '../Icons/Euro'
16
18
  import ExchangeIcon from '../Icons/Exchange'
@@ -51,13 +53,15 @@ function FileDuotoneWhite(props) {
51
53
  )
52
54
  }
53
55
 
54
- const qualificationIcon = {
56
+ const IconByLabel = {
55
57
  'bank-check': BankCheckIcon,
56
58
  bank: BankIcon,
57
59
  benefit: BenefitIcon,
58
60
  bill: BillIcon,
59
61
  car: CarIcon,
62
+ chess: ChessIcon,
60
63
  child: ChildIcon,
64
+ dots: DotsIcon,
61
65
  email: EmailIcon,
62
66
  euro: EuroIcon,
63
67
  exchange: ExchangeIcon,
@@ -84,8 +88,25 @@ const qualificationIcon = {
84
88
  work: WorkIcon
85
89
  }
86
90
 
87
- const QualificationIconStack = ({ qualification, ...props }) => {
88
- const QualificationIcon = qualificationIcon[getIconByLabel(qualification)]
91
+ const themeIconByLabel = {
92
+ identity: 'people',
93
+ family: 'team',
94
+ work_study: 'work',
95
+ health: 'heart',
96
+ home: 'home',
97
+ transport: 'car',
98
+ activity: 'chess',
99
+ finance: 'bank',
100
+ invoice: 'bill',
101
+ others: 'dots'
102
+ }
103
+
104
+ const QualificationIconStack = ({ theme, qualification, ...props }) => {
105
+ const ForegroundIcon = qualification
106
+ ? IconByLabel[getIconByLabel(qualification)]
107
+ : theme
108
+ ? IconByLabel[themeIconByLabel[theme]]
109
+ : null
89
110
 
90
111
  return (
91
112
  <IconStack
@@ -96,16 +117,16 @@ const QualificationIconStack = ({ qualification, ...props }) => {
96
117
  <Icon icon={FileDuotoneIcon} color="#E049BF" size={32} />
97
118
  </>
98
119
  }
99
- foregroundIcon={
100
- <Icon icon={QualificationIcon} color="#E049BF" size={16} />
101
- }
120
+ foregroundIcon={<Icon icon={ForegroundIcon} color="#E049BF" size={16} />}
102
121
  />
103
122
  )
104
123
  }
105
124
 
106
125
  QualificationIconStack.propTypes = {
107
126
  /** The name of the qualification (isp\_invoice, family\_record\_book, etc.) */
108
- qualification: PropTypes.string.isRequired
127
+ qualification: PropTypes.string,
128
+ /** The name of the qualification theme (indentity, family, etc.) */
129
+ theme: PropTypes.string
109
130
  }
110
131
 
111
132
  export default QualificationIconStack
@@ -17,7 +17,7 @@ const Slide = ({ number }) => {
17
17
  const handleClickPop = async () => {
18
18
  await stackPop()
19
19
 
20
- // No alerts during enzyme tests
20
+ // No alerts during tests
21
21
  if (number === 2 && !global.mount) {
22
22
  alert('You went back to the first slide')
23
23
  }
@@ -1,11 +1,11 @@
1
- import { renderHook, act } from '@testing-library/react-hooks'
2
- import { shallow } from 'enzyme'
1
+ import { screen, render, act } from '@testing-library/react'
2
+ import { renderHook } from '@testing-library/react-hooks'
3
3
  import React from 'react'
4
4
 
5
- import { CozyProvider } from 'cozy-client'
6
5
  import { FetchError } from 'cozy-stack-client'
7
6
 
8
7
  import useClientErrors from './useClientErrors'
8
+ import DemoProvider from '../providers/DemoProvider'
9
9
 
10
10
  function createCozyClient() {
11
11
  return {
@@ -14,9 +14,15 @@ function createCozyClient() {
14
14
  }
15
15
  }
16
16
 
17
+ jest.mock('../deprecated/QuotaAlert', () => ({ onClose }) => (
18
+ <>
19
+ QuotaAlert <button onClick={onClose}>Dismiss</button>
20
+ </>
21
+ ))
22
+
17
23
  function createWrapper(client = createCozyClient()) {
18
24
  function Wrapper({ children }) {
19
- return <CozyProvider client={client}>{children}</CozyProvider>
25
+ return <DemoProvider client={client}>{children}</DemoProvider>
20
26
  }
21
27
  return Wrapper
22
28
  }
@@ -27,7 +33,7 @@ function renderWrappedHook(client) {
27
33
  }
28
34
 
29
35
  function wrappedShallow(tree, client) {
30
- return shallow(tree, { wrappingComponent: createWrapper(client) })
36
+ return render(tree, { wrapper: createWrapper(client) })
31
37
  }
32
38
 
33
39
  describe('useClientErrors', () => {
@@ -47,14 +53,12 @@ describe('useClientErrors', () => {
47
53
  it('displays nothing by default', () => {
48
54
  const { result } = renderWrappedHook()
49
55
  const { ClientErrors } = result.current
50
- const node = wrappedShallow(<ClientErrors />)
51
- expect(node).toHaveLength(0)
56
+ wrappedShallow(<ClientErrors />)
57
+
58
+ expect(screen.queryByText('QuotaAlert')).not.toBeInTheDocument()
52
59
  })
53
60
 
54
61
  describe('for quota errors', () => {
55
- const findQuotaAlert = node => {
56
- return node.at(0).dive()
57
- }
58
62
  const setup = async () => {
59
63
  const client = createCozyClient()
60
64
  const response = new Response(null, {
@@ -81,21 +85,9 @@ describe('useClientErrors', () => {
81
85
  }
82
86
 
83
87
  it('displays a a QuotaAlert', async () => {
84
- const { node } = await setup()
85
- expect(node).toHaveLength(1)
86
- expect(findQuotaAlert(node).type().name).toEqual('QuotaAlert')
87
- })
88
-
89
- it('can be dismissed', async () => {
90
- const { node, result, client } = await setup()
91
- const quotaAlert = findQuotaAlert(node)
92
- const onClose = quotaAlert.props().onClose
93
- act(() => onClose())
88
+ await setup()
94
89
 
95
- // re-render ClientErrors returned by the hook
96
- const { ClientErrors } = result.current
97
- const updatedNode = wrappedShallow(<ClientErrors />, client)
98
- expect(updatedNode.at(0).length).toBe(0)
90
+ expect(screen.queryByText('QuotaAlert')).toBeInTheDocument()
99
91
  })
100
92
  })
101
93
  })
@@ -1,4 +1,4 @@
1
- import { render, fireEvent } from '@testing-library/react'
1
+ import { render, fireEvent, screen } from '@testing-library/react'
2
2
  import PropTypes from 'prop-types'
3
3
  import React, { useState } from 'react'
4
4
 
@@ -34,23 +34,31 @@ I18nHelloWorldOldAPI.contextTypes = {
34
34
 
35
35
  describe('new context api', () => {
36
36
  it('should provide t and f and lang through useI18n hook', () => {
37
- const root = mount(
37
+ render(
38
38
  <I18n lang="en" dictRequire={() => locales}>
39
39
  <I18nHelloWorldHook />
40
40
  </I18n>
41
41
  )
42
- expect(root.html()).toBe('<div>Hello World !<br>6 Jan<br>en</div>')
42
+ expect(
43
+ screen.getByText('Hello World !', { exact: false })
44
+ ).toBeInTheDocument()
45
+ expect(screen.getByText('6 Jan', { exact: false })).toBeInTheDocument()
46
+ expect(screen.getByText('en', { exact: false })).toBeInTheDocument()
43
47
  })
44
48
  })
45
49
 
46
50
  describe('old context api', () => {
47
51
  it('should provide t and f and lang through old context API', () => {
48
- const root = mount(
52
+ render(
49
53
  <I18n lang="en" dictRequire={() => locales}>
50
54
  <I18nHelloWorldOldAPI />
51
55
  </I18n>
52
56
  )
53
- expect(root.html()).toBe('<div>Hello World !<br>6 Jan<br>en</div>')
57
+ expect(
58
+ screen.getByText('Hello World !', { exact: false })
59
+ ).toBeInTheDocument()
60
+ expect(screen.getByText('6 Jan', { exact: false })).toBeInTheDocument()
61
+ expect(screen.getByText('en', { exact: false })).toBeInTheDocument()
54
62
  })
55
63
  })
56
64
 
@@ -1,3 +1,4 @@
1
+ import { render, screen } from '@testing-library/react'
1
2
  import React from 'react'
2
3
 
3
4
  import { I18n } from '.'
@@ -29,9 +30,8 @@ class MockComponent extends React.Component {
29
30
  }
30
31
 
31
32
  describe('with locales', () => {
32
- let root
33
33
  const setup = ({ lang, Component }) => {
34
- root = mount(
34
+ render(
35
35
  <I18n lang={lang} dictRequire={localeCode => globalLocales[localeCode]}>
36
36
  <Component />
37
37
  </I18n>
@@ -42,9 +42,9 @@ describe('with locales', () => {
42
42
  describe(description, () => {
43
43
  it('should provide t with correct locale strings', () => {
44
44
  setup({ lang: 'en', Component })
45
- expect(root.text()).toBe('Hello local world !')
45
+ expect(screen.getByText('Hello local world !')).toBeInTheDocument()
46
46
  setup({ lang: 'fr', Component })
47
- expect(root.text()).toBe('Bonjour le monde local !')
47
+ expect(screen.getByText('Bonjour le monde local !')).toBeInTheDocument()
48
48
  })
49
49
  })
50
50
  }
@@ -47,7 +47,8 @@ var FileInput = function FileInput(_ref) {
47
47
  } else {
48
48
  _onChange(Array.from(e.target.files)[0]);
49
49
  }
50
- }
50
+ },
51
+ "data-testid": "file-input"
51
52
  }, inputProps)));
52
53
  };
53
54
 
@@ -1,6 +1,6 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
- var _excluded = ["qualification"];
3
+ var _excluded = ["theme", "qualification"];
4
4
  import PropTypes from 'prop-types';
5
5
  import React from 'react';
6
6
  import { getIconByLabel } from 'cozy-client/dist/models/document/qualification';
@@ -11,7 +11,9 @@ import BankCheckIcon from "cozy-ui/transpiled/react/Icons/BankCheck";
11
11
  import BenefitIcon from "cozy-ui/transpiled/react/Icons/Benefit";
12
12
  import BillIcon from "cozy-ui/transpiled/react/Icons/Bill";
13
13
  import CarIcon from "cozy-ui/transpiled/react/Icons/Car";
14
+ import ChessIcon from "cozy-ui/transpiled/react/Icons/Chess";
14
15
  import ChildIcon from "cozy-ui/transpiled/react/Icons/Child";
16
+ import DotsIcon from "cozy-ui/transpiled/react/Icons/Dots";
15
17
  import EmailIcon from "cozy-ui/transpiled/react/Icons/Email";
16
18
  import EuroIcon from "cozy-ui/transpiled/react/Icons/Euro";
17
19
  import ExchangeIcon from "cozy-ui/transpiled/react/Icons/Exchange";
@@ -49,13 +51,15 @@ function FileDuotoneWhite(props) {
49
51
  })));
50
52
  }
51
53
 
52
- var qualificationIcon = {
54
+ var IconByLabel = {
53
55
  'bank-check': BankCheckIcon,
54
56
  bank: BankIcon,
55
57
  benefit: BenefitIcon,
56
58
  bill: BillIcon,
57
59
  car: CarIcon,
60
+ chess: ChessIcon,
58
61
  child: ChildIcon,
62
+ dots: DotsIcon,
59
63
  email: EmailIcon,
60
64
  euro: EuroIcon,
61
65
  exchange: ExchangeIcon,
@@ -81,12 +85,25 @@ var qualificationIcon = {
81
85
  water: WaterIcon,
82
86
  work: WorkIcon
83
87
  };
88
+ var themeIconByLabel = {
89
+ identity: 'people',
90
+ family: 'team',
91
+ work_study: 'work',
92
+ health: 'heart',
93
+ home: 'home',
94
+ transport: 'car',
95
+ activity: 'chess',
96
+ finance: 'bank',
97
+ invoice: 'bill',
98
+ others: 'dots'
99
+ };
84
100
 
85
101
  var QualificationIconStack = function QualificationIconStack(_ref) {
86
- var qualification = _ref.qualification,
102
+ var theme = _ref.theme,
103
+ qualification = _ref.qualification,
87
104
  props = _objectWithoutProperties(_ref, _excluded);
88
105
 
89
- var QualificationIcon = qualificationIcon[getIconByLabel(qualification)];
106
+ var ForegroundIcon = qualification ? IconByLabel[getIconByLabel(qualification)] : theme ? IconByLabel[themeIconByLabel[theme]] : null;
90
107
  return /*#__PURE__*/React.createElement(IconStack, _extends({}, props, {
91
108
  backgroundIcon: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Icon, {
92
109
  className: "u-pos-absolute",
@@ -98,7 +115,7 @@ var QualificationIconStack = function QualificationIconStack(_ref) {
98
115
  size: 32
99
116
  })),
100
117
  foregroundIcon: /*#__PURE__*/React.createElement(Icon, {
101
- icon: QualificationIcon,
118
+ icon: ForegroundIcon,
102
119
  color: "#E049BF",
103
120
  size: 16
104
121
  })
@@ -107,6 +124,9 @@ var QualificationIconStack = function QualificationIconStack(_ref) {
107
124
 
108
125
  QualificationIconStack.propTypes = {
109
126
  /** The name of the qualification (isp\_invoice, family\_record\_book, etc.) */
110
- qualification: PropTypes.string.isRequired
127
+ qualification: PropTypes.string,
128
+
129
+ /** The name of the qualification theme (indentity, family, etc.) */
130
+ theme: PropTypes.string
111
131
  };
112
132
  export default QualificationIconStack;
@@ -34,7 +34,7 @@ var Slide = function Slide(_ref2) {
34
34
  return stackPop();
35
35
 
36
36
  case 2:
37
- // No alerts during enzyme tests
37
+ // No alerts during tests
38
38
  if (number === 2 && !global.mount) {
39
39
  alert('You went back to the first slide');
40
40
  }