cozy-ui 113.8.0 → 114.0.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.
- package/CHANGELOG.md +20 -0
- package/jest.config.js +1 -2
- package/package.json +6 -12
- package/react/AppSections/components/AppsSection.spec.jsx +10 -19
- package/react/AppSections/index.spec.jsx +98 -77
- package/react/ContactsList/ContactRow.spec.js +28 -53
- package/react/DateMonthPicker/index.spec.jsx +17 -45
- package/react/Field/index.spec.js +28 -5
- package/react/Figure/Figure.spec.jsx +9 -4
- package/react/Figure/__snapshots__/Figure.spec.jsx.snap +289 -225
- package/react/FileInput/index.jsx +1 -0
- package/react/FileInput/index.spec.jsx +16 -38
- package/react/Paywall/Paywall.spec.jsx +3 -5
- package/react/Popup/index.spec.jsx +90 -41
- package/react/QualificationIconStack/Readme.md +4 -1
- package/react/QualificationIconStack/index.jsx +28 -7
- package/react/QualificationModal/Readme.md +28 -0
- package/react/QualificationModal/index.jsx +94 -0
- package/react/QualificationModal/locales/en.json +5 -0
- package/react/QualificationModal/locales/fr.json +5 -0
- package/react/QualificationModal/locales/index.jsx +7 -0
- package/react/deprecated/ViewStack/example.jsx +1 -1
- package/react/hooks/useClientErrors.spec.jsx +16 -24
- package/react/index.js +2 -0
- package/react/providers/I18n/index.spec.jsx +13 -5
- package/react/providers/I18n/withLocales.spec.jsx +4 -4
- package/transpiled/react/FileInput/index.js +2 -1
- package/transpiled/react/QualificationIconStack/index.js +26 -6
- package/transpiled/react/QualificationModal/index.js +126 -0
- package/transpiled/react/QualificationModal/locales/index.js +14 -0
- package/transpiled/react/deprecated/ViewStack/example.js +1 -1
- package/transpiled/react/index.js +2 -0
- package/react/AppSections/__snapshots__/index.spec.jsx.snap +0 -1843
- package/react/AppSections/components/__snapshots__/AppsSection.spec.jsx.snap +0 -41
- package/react/ContactsList/__snapshots__/ContactRow.spec.js.snap +0 -69
- package/react/FileInput/__snapshots__/index.spec.jsx.snap +0 -86
- package/react/Input/__snapshots__/index.spec.jsx.snap +0 -11
- package/react/Input/index.spec.jsx +0 -12
- package/react/__snapshots__/examples.spec.jsx.snap +0 -3720
- package/react/deprecated/ActionMenu/__snapshots__/index.spec.jsx.snap +0 -157
- package/react/deprecated/ActionMenu/index.spec.jsx +0 -115
- package/react/deprecated/Alerter/__snapshots__/alerter.spec.js.snap +0 -88
- package/react/deprecated/Alerter/alerter.spec.js +0 -78
- package/react/deprecated/InfosCarrousel/index.spec.jsx +0 -71
- package/react/deprecated/Modal/index.spec.jsx +0 -70
- package/react/deprecated/ViewStack/index.spec.jsx +0 -64
- package/react/examples.spec.jsx +0 -67
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
# [114.0.0](https://github.com/cozy/cozy-ui/compare/v113.9.0...v114.0.0) (2024-12-12)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Add QualificationModal component ([e2ebcc0](https://github.com/cozy/cozy-ui/commit/e2ebcc0))
|
|
7
|
+
* Upgrade packages ([4ca7867](https://github.com/cozy/cozy-ui/commit/4ca7867))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
|
|
12
|
+
* You must have `cozy-client >= 51.6.0` and `cozy-intent >= 2.29.1`
|
|
13
|
+
|
|
14
|
+
# [113.9.0](https://github.com/cozy/cozy-ui/compare/v113.8.0...v113.9.0) (2024-12-10)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **QualificationIconStack:** Add `theme` props ([61081a1](https://github.com/cozy/cozy-ui/commit/61081a1))
|
|
20
|
+
|
|
1
21
|
# [113.8.0](https://github.com/cozy/cozy-ui/compare/v113.7.1...v113.8.0) (2024-12-04)
|
|
2
22
|
|
|
3
23
|
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "114.0.0",
|
|
4
4
|
"description": "Cozy apps UI SDK",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"bin": {
|
|
@@ -48,8 +48,6 @@
|
|
|
48
48
|
"sprite": "scripts/make-icon-sprite.sh",
|
|
49
49
|
"screenshots": "node scripts/screenshots.js --screenshot-dir ./screenshots --styleguide-url file://$(pwd)/build/react --kss-dir ./build/styleguide",
|
|
50
50
|
"test": "jest",
|
|
51
|
-
"test:noSnapshots": "jest --testPathIgnorePatterns 'react/examples.spec.jsx'",
|
|
52
|
-
"test:snapshots": "jest react/examples.spec.jsx",
|
|
53
51
|
"screenshots:server": "nodemon ./scripts/pixelmatch-server/server.js -e js,hbs",
|
|
54
52
|
"postbuild": "postcss transpiled/react/stylesheet.css --replace",
|
|
55
53
|
"travis-deploy-once": "travis-deploy-once",
|
|
@@ -94,18 +92,15 @@
|
|
|
94
92
|
"browserslist-config-cozy": "0.4.0",
|
|
95
93
|
"bundlemon": "3.1.0",
|
|
96
94
|
"copyfiles": "2.4.1",
|
|
97
|
-
"cozy-client": "^
|
|
95
|
+
"cozy-client": "^51.6.0",
|
|
98
96
|
"cozy-device-helper": "2.0.0",
|
|
99
97
|
"cozy-flags": "^2.10.1",
|
|
100
|
-
"cozy-intent": "
|
|
98
|
+
"cozy-intent": "^2.29.1",
|
|
101
99
|
"cozy-logger": "^1.9.0",
|
|
102
|
-
"cozy-stack-client": "^
|
|
100
|
+
"cozy-stack-client": "^51.6.0",
|
|
103
101
|
"css-loader": "0.28.11",
|
|
104
102
|
"cssnano": "4.1.11",
|
|
105
103
|
"cssnano-preset-advanced": "4.0.8",
|
|
106
|
-
"enzyme": "3.11.0",
|
|
107
|
-
"enzyme-adapter-react-16": "1.15.6",
|
|
108
|
-
"enzyme-to-json": "3.6.2",
|
|
109
104
|
"eslint": "8.11.0",
|
|
110
105
|
"eslint-config-cozy-app": "^6.1.0",
|
|
111
106
|
"eslint-config-prettier": "8.6.0",
|
|
@@ -134,7 +129,6 @@
|
|
|
134
129
|
"postcss-cli": "6.1.3",
|
|
135
130
|
"postcss-loader": "2.1.6",
|
|
136
131
|
"prettier": "2.6.0",
|
|
137
|
-
"pretty": "2.0.0",
|
|
138
132
|
"prop-types": "15.7.2",
|
|
139
133
|
"react": "16.12.0",
|
|
140
134
|
"react-dom": "16.12.0",
|
|
@@ -187,9 +181,9 @@
|
|
|
187
181
|
"rooks": "^5.11.2"
|
|
188
182
|
},
|
|
189
183
|
"peerDependencies": {
|
|
190
|
-
"cozy-client": ">=
|
|
184
|
+
"cozy-client": ">=51.6.0",
|
|
191
185
|
"cozy-device-helper": "^2.0.0",
|
|
192
|
-
"cozy-intent": ">=
|
|
186
|
+
"cozy-intent": ">=2.29.1",
|
|
193
187
|
"react": "^16.8.6",
|
|
194
188
|
"react-dom": "^16.8.6"
|
|
195
189
|
},
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
/* eslint-env jest */
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
6
6
|
import React from 'react'
|
|
7
7
|
|
|
8
8
|
import { CozyProvider } from 'cozy-client'
|
|
9
9
|
|
|
10
10
|
import { AppsSection } from './AppsSection'
|
|
11
|
-
import Tile, { TileTitle, TileSubtitle, TileFooter } from '../../Tile'
|
|
12
11
|
import { I18nContext } from '../../jestLib/I18n'
|
|
13
12
|
import mockApps from '../../mocks/apps'
|
|
14
13
|
import { BreakpointsProvider } from '../../providers/Breakpoints'
|
|
@@ -19,10 +18,9 @@ const i18nContext = I18nContext({ locale: en })
|
|
|
19
18
|
const tMock = i18nContext.t
|
|
20
19
|
|
|
21
20
|
describe('AppsSection component', () => {
|
|
22
|
-
let component
|
|
23
21
|
const client = {}
|
|
24
22
|
const setup = ({ onAppClick }) => {
|
|
25
|
-
|
|
23
|
+
render(
|
|
26
24
|
<CozyProvider client={client}>
|
|
27
25
|
<BreakpointsProvider>
|
|
28
26
|
<I18n lang="en" dictRequire={() => en}>
|
|
@@ -36,31 +34,24 @@ describe('AppsSection component', () => {
|
|
|
36
34
|
</I18n>
|
|
37
35
|
</BreakpointsProvider>
|
|
38
36
|
</CozyProvider>
|
|
39
|
-
)
|
|
37
|
+
)
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
it('should be rendered correctly with apps list, subtitle', () => {
|
|
43
41
|
const mockOnAppClick = jest.fn()
|
|
44
42
|
setup({ onAppClick: mockOnAppClick })
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
title: x.find(TileTitle).text(),
|
|
51
|
-
developer: developer.length ? developer.text() : null,
|
|
52
|
-
status: status.length ? status.text() : null
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
).toMatchSnapshot()
|
|
43
|
+
|
|
44
|
+
mockApps.forEach(app => {
|
|
45
|
+
expect(screen.getByText(app.name, { exact: false })).toBeInTheDocument()
|
|
46
|
+
})
|
|
56
47
|
})
|
|
57
48
|
|
|
58
49
|
it('should run provided onAppClick on AppTile click event', () => {
|
|
59
50
|
const mockOnAppClick = jest.fn()
|
|
60
51
|
setup({ onAppClick: mockOnAppClick })
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
52
|
+
|
|
53
|
+
const bouilligue = screen.getByText('Bouilligue', { exact: false })
|
|
54
|
+
fireEvent.click(bouilligue)
|
|
64
55
|
expect(mockOnAppClick.mock.calls.length).toBe(1)
|
|
65
56
|
expect(mockOnAppClick.mock.calls[0][0]).toBe('konnector-bouilligue')
|
|
66
57
|
})
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
/* eslint-env jest */
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { render, screen } from '@testing-library/react'
|
|
6
6
|
import React from 'react'
|
|
7
7
|
|
|
8
8
|
import { Sections } from './Sections'
|
|
9
9
|
import en from './locales/en.json'
|
|
10
10
|
import { I18nContext } from '../jestLib/I18n'
|
|
11
11
|
import mockApps from '../mocks/apps'
|
|
12
|
+
import DemoProvider from '../providers/DemoProvider'
|
|
12
13
|
|
|
13
14
|
const i18nContext = I18nContext({ locale: en })
|
|
14
15
|
const tMock = i18nContext.t
|
|
@@ -16,101 +17,121 @@ const tMock = i18nContext.t
|
|
|
16
17
|
describe('AppsSection component', () => {
|
|
17
18
|
it('should be rendered correctly with apps list, subtitle and onAppClick', () => {
|
|
18
19
|
const mockOnAppClick = jest.fn()
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
render(
|
|
21
|
+
<DemoProvider>
|
|
22
|
+
<Sections
|
|
23
|
+
t={tMock}
|
|
24
|
+
lang="en"
|
|
25
|
+
subtitle="Test Apps"
|
|
26
|
+
apps={mockApps}
|
|
27
|
+
allApps={mockApps}
|
|
28
|
+
onAppClick={mockOnAppClick}
|
|
29
|
+
error={null}
|
|
30
|
+
location={{ search: '' }}
|
|
31
|
+
/>
|
|
32
|
+
</DemoProvider>
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
expect(screen.queryByText('Cozy Collect')).toBeInTheDocument()
|
|
36
|
+
expect(screen.queryByText('Cozy Drive')).toBeInTheDocument()
|
|
37
|
+
expect(screen.queryByText('DevOnly')).toBeInTheDocument()
|
|
32
38
|
})
|
|
33
39
|
|
|
34
40
|
it('should render correctly render message if error provided', () => {
|
|
35
41
|
const mockOnAppClick = jest.fn()
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
render(
|
|
43
|
+
<DemoProvider>
|
|
44
|
+
<Sections
|
|
45
|
+
t={tMock}
|
|
46
|
+
lang="en"
|
|
47
|
+
subtitle="Test Apps"
|
|
48
|
+
apps={mockApps}
|
|
49
|
+
allApps={mockApps}
|
|
50
|
+
onAppClick={mockOnAppClick}
|
|
51
|
+
error={new Error('This is a test error')}
|
|
52
|
+
location={{ search: '' }}
|
|
53
|
+
/>
|
|
54
|
+
</DemoProvider>
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
expect(screen.queryByText('This is a test error')).toBeInTheDocument()
|
|
49
58
|
})
|
|
50
59
|
|
|
51
60
|
it('should not render dropdown filter on mobile if nav=false flag provided', () => {
|
|
52
61
|
const mockOnAppClick = jest.fn()
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
render(
|
|
63
|
+
<DemoProvider>
|
|
64
|
+
<Sections
|
|
65
|
+
t={tMock}
|
|
66
|
+
lang="en"
|
|
67
|
+
subtitle="Test Apps"
|
|
68
|
+
apps={mockApps}
|
|
69
|
+
allApps={mockApps}
|
|
70
|
+
onAppClick={mockOnAppClick}
|
|
71
|
+
breakpoints={{ isMobile: true }}
|
|
72
|
+
hasNav={false}
|
|
73
|
+
/>
|
|
74
|
+
</DemoProvider>
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
expect(screen.queryByText('All categories')).not.toBeInTheDocument()
|
|
66
78
|
})
|
|
67
79
|
|
|
68
80
|
it('should not render dropdown filter on tablet if nav=false flag provided', () => {
|
|
69
81
|
const mockOnAppClick = jest.fn()
|
|
70
|
-
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
render(
|
|
83
|
+
<DemoProvider>
|
|
84
|
+
<Sections
|
|
85
|
+
t={tMock}
|
|
86
|
+
lang="en"
|
|
87
|
+
subtitle="Test Apps"
|
|
88
|
+
apps={mockApps}
|
|
89
|
+
allApps={mockApps}
|
|
90
|
+
onAppClick={mockOnAppClick}
|
|
91
|
+
breakpoints={{ isTablet: true }}
|
|
92
|
+
hasNav={false}
|
|
93
|
+
/>
|
|
94
|
+
</DemoProvider>
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
expect(screen.queryByText('All categories')).not.toBeInTheDocument()
|
|
83
98
|
})
|
|
84
99
|
|
|
85
100
|
it('should render dropdown filter on mobile if no nav=false flag provided', () => {
|
|
86
101
|
const mockOnAppClick = jest.fn()
|
|
87
|
-
|
|
88
|
-
<
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
render(
|
|
103
|
+
<DemoProvider>
|
|
104
|
+
<Sections
|
|
105
|
+
t={tMock}
|
|
106
|
+
lang="en"
|
|
107
|
+
subtitle="Test Apps"
|
|
108
|
+
apps={mockApps}
|
|
109
|
+
allApps={mockApps}
|
|
110
|
+
onAppClick={mockOnAppClick}
|
|
111
|
+
breakpoints={{ isMobile: true }}
|
|
112
|
+
/>
|
|
113
|
+
</DemoProvider>
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
expect(screen.queryByText('All categories')).toBeInTheDocument()
|
|
99
117
|
})
|
|
100
118
|
|
|
101
119
|
it('should render dropdown filter on tablet if no nav=false flag provided', () => {
|
|
102
120
|
const mockOnAppClick = jest.fn()
|
|
103
|
-
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
121
|
+
render(
|
|
122
|
+
<DemoProvider>
|
|
123
|
+
<Sections
|
|
124
|
+
t={tMock}
|
|
125
|
+
lang="en"
|
|
126
|
+
subtitle="Test Apps"
|
|
127
|
+
apps={mockApps}
|
|
128
|
+
allApps={mockApps}
|
|
129
|
+
onAppClick={mockOnAppClick}
|
|
130
|
+
breakpoints={{ isTablet: true }}
|
|
131
|
+
/>
|
|
132
|
+
</DemoProvider>
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
expect(screen.queryByText('All categories')).toBeInTheDocument()
|
|
115
136
|
})
|
|
116
137
|
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen } from '@testing-library/react'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import renderer from 'react-test-renderer'
|
|
4
3
|
|
|
5
4
|
import logger from 'cozy-logger'
|
|
6
5
|
|
|
@@ -16,20 +15,22 @@ const makeContact = attrs => ({
|
|
|
16
15
|
})
|
|
17
16
|
|
|
18
17
|
const setup = ({ contact }) => {
|
|
19
|
-
|
|
18
|
+
render(
|
|
20
19
|
<BreakpointsProvider>
|
|
21
20
|
<ContactRow contact={contact} />
|
|
22
21
|
</BreakpointsProvider>
|
|
23
22
|
)
|
|
24
|
-
return { root }
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
describe('ContactRow', () => {
|
|
28
26
|
it('should accept the strict minimum', () => {
|
|
29
27
|
const contact = makeContact({ email: [{ address: 'johndoe@localhost' }] })
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
setup({ contact })
|
|
29
|
+
|
|
30
|
+
// With a minimal contact, email is displayed twice
|
|
31
|
+
// - one as display name
|
|
32
|
+
// - one as email
|
|
33
|
+
expect(screen.getAllByText('johndoe@localhost').length).toBe(2)
|
|
33
34
|
})
|
|
34
35
|
|
|
35
36
|
it('should display data', () => {
|
|
@@ -39,62 +40,36 @@ describe('ContactRow', () => {
|
|
|
39
40
|
email: [{ address: 'johndoe@localhost' }],
|
|
40
41
|
cozy: [{ url: 'http://johndoe.mycozy.cloud' }]
|
|
41
42
|
})
|
|
42
|
-
|
|
43
|
-
const contactrowname = root.find('ContactName')
|
|
44
|
-
expect(contactrowname).toBeDefined()
|
|
45
|
-
expect(contactrowname.text()).toEqual(
|
|
46
|
-
expect.stringContaining(contact.name.givenName)
|
|
47
|
-
)
|
|
48
|
-
expect(contactrowname.text()).toEqual(
|
|
49
|
-
expect.stringContaining(contact.name.familyName)
|
|
50
|
-
)
|
|
51
|
-
const contactrowphone = root.find('ContactPhone')
|
|
52
|
-
expect(contactrowphone).toBeDefined()
|
|
53
|
-
expect(contactrowphone.text()).toBe(contact.phone[0].number)
|
|
43
|
+
setup({ contact })
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
expect(
|
|
57
|
-
expect(
|
|
45
|
+
// We need to check first and last name separatly because they are in two different span
|
|
46
|
+
expect(screen.getByText('John')).toBeInTheDocument()
|
|
47
|
+
expect(screen.getByText('Doe')).toBeInTheDocument()
|
|
48
|
+
expect(screen.getByText('0123456789')).toBeInTheDocument()
|
|
49
|
+
expect(screen.getByText('johndoe@localhost')).toBeInTheDocument()
|
|
50
|
+
expect(screen.getByText('http://johndoe.mycozy.cloud')).toBeInTheDocument()
|
|
58
51
|
})
|
|
59
52
|
|
|
60
53
|
it('should display email for missing information', () => {
|
|
61
54
|
const contact = makeContact({
|
|
62
55
|
email: [{ address: 'johndoe@localhost' }]
|
|
63
56
|
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
expect(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
expect(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
expect(
|
|
57
|
+
setup({ contact })
|
|
58
|
+
|
|
59
|
+
const emailColumn = screen.getByTestId('ContactEmail')
|
|
60
|
+
expect(emailColumn.textContent).toBe('johndoe@localhost')
|
|
61
|
+
|
|
62
|
+
const phoneColumn = screen.getByTestId('ContactPhone')
|
|
63
|
+
expect(phoneColumn.textContent).toBe('—')
|
|
64
|
+
|
|
65
|
+
const cozyColumn = screen.getByTestId('ContactCozy')
|
|
66
|
+
expect(cozyColumn.textContent).toBe('—')
|
|
74
67
|
})
|
|
75
68
|
|
|
76
69
|
it('should accept empty array', () => {
|
|
77
70
|
const contact = makeContact({ email: [] })
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
expect(
|
|
81
|
-
expect(contactrowemail.text()).toBe('—')
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
it('should match the contact snapshot', () => {
|
|
85
|
-
const contact = makeContact({
|
|
86
|
-
name: { familyName: 'Doe', givenName: 'John' },
|
|
87
|
-
phone: [{ number: '0123456789' }],
|
|
88
|
-
email: [{ address: 'johndoe@localhost' }],
|
|
89
|
-
cozy: [{ url: 'http://johndoe.mycozy.cloud' }]
|
|
90
|
-
})
|
|
91
|
-
const tree = renderer
|
|
92
|
-
.create(
|
|
93
|
-
<BreakpointsProvider>
|
|
94
|
-
<ContactRow contact={contact} />
|
|
95
|
-
</BreakpointsProvider>
|
|
96
|
-
)
|
|
97
|
-
.toJSON()
|
|
98
|
-
expect(tree).toMatchSnapshot()
|
|
71
|
+
setup({ contact })
|
|
72
|
+
const emailColumn = screen.getByTestId('ContactEmail')
|
|
73
|
+
expect(emailColumn.textContent).toBe('—')
|
|
99
74
|
})
|
|
100
75
|
})
|
|
@@ -1,36 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
2
2
|
import React from 'react'
|
|
3
|
-
import { act } from 'react-dom/test-utils'
|
|
4
3
|
|
|
5
4
|
import DateMonthPicker from '.'
|
|
6
|
-
import LeftIcon from '../Icons/Left'
|
|
7
|
-
import RightIcon from '../Icons/Right'
|
|
8
5
|
import I18n from '../providers/I18n'
|
|
9
6
|
|
|
10
|
-
const findButtonWithLabel = (root, label) =>
|
|
11
|
-
root.findWhere(n => n.type() == 'button' && n.props().children === label)
|
|
12
|
-
|
|
13
|
-
const findButtonWithIcon = (root, iconName) =>
|
|
14
|
-
root.findWhere(n => {
|
|
15
|
-
const props = n.props()
|
|
16
|
-
if (n.type() !== 'button') {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
if (!props.children || !props.children.length > 1) {
|
|
20
|
-
return
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
props.children.props &&
|
|
25
|
-
props.children.props.icon &&
|
|
26
|
-
props.children.props.icon == iconName
|
|
27
|
-
)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
7
|
describe('DateMonthPicker', () => {
|
|
31
8
|
const setup = ({ initialValue }) => {
|
|
32
9
|
const handleSelect = jest.fn()
|
|
33
|
-
const root =
|
|
10
|
+
const root = render(
|
|
34
11
|
<I18n lang="en" dictRequire={() => {}}>
|
|
35
12
|
<DateMonthPicker initialValue={initialValue} onSelect={handleSelect} />
|
|
36
13
|
</I18n>
|
|
@@ -39,36 +16,31 @@ describe('DateMonthPicker', () => {
|
|
|
39
16
|
}
|
|
40
17
|
|
|
41
18
|
it('should be able to select a month', async () => {
|
|
42
|
-
const {
|
|
43
|
-
const februaryButton =
|
|
44
|
-
|
|
45
|
-
februaryButton.props().onClick()
|
|
19
|
+
const { handleSelect } = setup({ initialValue: '2015-08' })
|
|
20
|
+
const februaryButton = screen.getByText('Feb')
|
|
21
|
+
fireEvent.click(februaryButton)
|
|
46
22
|
expect(handleSelect).toHaveBeenCalledTimes(1)
|
|
47
23
|
expect(handleSelect).toHaveBeenCalledWith('2015-02-01')
|
|
48
24
|
})
|
|
49
25
|
|
|
50
26
|
it('should be able to go to previous year', async () => {
|
|
51
|
-
const {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const februaryButton = findButtonWithLabel(root, 'Feb')
|
|
58
|
-
februaryButton.props().onClick()
|
|
27
|
+
const { handleSelect } = setup({ initialValue: '2015-08' })
|
|
28
|
+
// Left arrow to go to previous year is first button
|
|
29
|
+
const previousYearButton = screen.getAllByRole('button')[0]
|
|
30
|
+
fireEvent.click(previousYearButton)
|
|
31
|
+
const februaryButton = screen.getByText('Feb')
|
|
32
|
+
fireEvent.click(februaryButton)
|
|
59
33
|
expect(handleSelect).toHaveBeenCalledTimes(1)
|
|
60
34
|
expect(handleSelect).toHaveBeenCalledWith('2014-02-01')
|
|
61
35
|
})
|
|
62
36
|
|
|
63
37
|
it('should be able to go to next year', async () => {
|
|
64
|
-
const {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const februaryButton = findButtonWithLabel(root, 'Feb')
|
|
71
|
-
februaryButton.props().onClick()
|
|
38
|
+
const { handleSelect } = setup({ initialValue: '2015-08' })
|
|
39
|
+
// Right arrow to go to next year is first button
|
|
40
|
+
const nextYearButton = screen.getAllByRole('button')[1]
|
|
41
|
+
fireEvent.click(nextYearButton)
|
|
42
|
+
const februaryButton = screen.getByText('Feb')
|
|
43
|
+
fireEvent.click(februaryButton)
|
|
72
44
|
expect(handleSelect).toHaveBeenCalledTimes(1)
|
|
73
45
|
expect(handleSelect).toHaveBeenCalledWith('2016-02-01')
|
|
74
46
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
2
2
|
import React from 'react'
|
|
3
3
|
|
|
4
4
|
import Field from '.'
|
|
@@ -18,19 +18,42 @@ describe('Field component', () => {
|
|
|
18
18
|
|
|
19
19
|
it('should expect object type value for type=select', () => {
|
|
20
20
|
expect(() =>
|
|
21
|
-
|
|
21
|
+
render(
|
|
22
|
+
<Field
|
|
23
|
+
label="mock field"
|
|
24
|
+
type="select"
|
|
25
|
+
value={{}}
|
|
26
|
+
onChange={() => {}}
|
|
27
|
+
/>
|
|
28
|
+
)
|
|
22
29
|
).not.toThrowError()
|
|
23
30
|
expect(() =>
|
|
24
|
-
|
|
31
|
+
render(
|
|
32
|
+
<Field
|
|
33
|
+
label="mock field"
|
|
34
|
+
type="select"
|
|
35
|
+
value="wrong"
|
|
36
|
+
onChange={() => {}}
|
|
37
|
+
/>
|
|
38
|
+
)
|
|
25
39
|
).toThrowError()
|
|
26
40
|
})
|
|
27
41
|
|
|
28
42
|
it('should expect string type value for all types but select', () => {
|
|
29
43
|
expect(() =>
|
|
30
|
-
|
|
44
|
+
render(
|
|
45
|
+
<Field
|
|
46
|
+
label="mock field"
|
|
47
|
+
type="text"
|
|
48
|
+
value="good"
|
|
49
|
+
onChange={() => {}}
|
|
50
|
+
/>
|
|
51
|
+
)
|
|
31
52
|
).not.toThrowError()
|
|
32
53
|
expect(() =>
|
|
33
|
-
|
|
54
|
+
render(
|
|
55
|
+
<Field label="mock field" type="text" value={{}} onChange={() => {}} />
|
|
56
|
+
)
|
|
34
57
|
).toThrowError()
|
|
35
58
|
})
|
|
36
59
|
})
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render } from '@testing-library/react'
|
|
2
2
|
import { flatten, merge } from 'lodash'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
|
|
@@ -39,13 +39,18 @@ describe('Figure', () => {
|
|
|
39
39
|
return merge.apply(null, [{}, ...attrs])
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
+
// We check for different king of amounts if
|
|
43
|
+
// - its red if it is negative if coloredNegative is set
|
|
44
|
+
// - its green if it is positive if coloredPositive is set
|
|
45
|
+
// - its yellow if it is above the warning limit if coloredWarning is set
|
|
46
|
+
|
|
42
47
|
for (let amount of amounts) {
|
|
43
48
|
for (let attrs of combinations) {
|
|
44
49
|
it(`should render correctly ${amount} ${formatAttrs(attrs)}`, () => {
|
|
45
|
-
const
|
|
50
|
+
const { container } = render(
|
|
46
51
|
<Figure warningLimit={110} total={amount} {...attrs} />
|
|
47
|
-
)
|
|
48
|
-
expect(
|
|
52
|
+
)
|
|
53
|
+
expect(container).toMatchSnapshot()
|
|
49
54
|
})
|
|
50
55
|
}
|
|
51
56
|
}
|