cozy-ui 110.8.1 → 110.8.2
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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [110.8.2](https://github.com/cozy/cozy-ui/compare/v110.8.1...v110.8.2) (2024-07-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **ViewerControls:** children can contain undefined values ([506fd4c](https://github.com/cozy/cozy-ui/commit/506fd4c))
|
|
7
|
+
|
|
1
8
|
## [110.8.1](https://github.com/cozy/cozy-ui/compare/v110.8.0...v110.8.1) (2024-07-10)
|
|
2
9
|
|
|
3
10
|
|
package/jest.config.js
CHANGED
|
@@ -14,7 +14,9 @@ module.exports = {
|
|
|
14
14
|
'react-pdf/dist/esm/entry.webpack': 'react-pdf',
|
|
15
15
|
'^cozy-client$': 'cozy-client/dist/index'
|
|
16
16
|
},
|
|
17
|
-
transformIgnorePatterns: [
|
|
17
|
+
transformIgnorePatterns: [
|
|
18
|
+
'node_modules/(?!(react-styleguidist|cozy-harvest-lib)/)'
|
|
19
|
+
],
|
|
18
20
|
testPathIgnorePatterns: ['/node_modules/', '/transpiled/', '/dist/'],
|
|
19
21
|
transform: {
|
|
20
22
|
'^.+\\.(ts|tsx|js|jsx)?$': 'babel-jest'
|
package/package.json
CHANGED
|
@@ -95,8 +95,8 @@ class ViewerControls extends Component {
|
|
|
95
95
|
|
|
96
96
|
return React.Children.map(children, child => {
|
|
97
97
|
if (
|
|
98
|
-
child
|
|
99
|
-
child
|
|
98
|
+
child?.type?.name === 'ViewerByFile' ||
|
|
99
|
+
child?.type?.displayName === 'ViewerByFile'
|
|
100
100
|
) {
|
|
101
101
|
return React.cloneElement(child, {
|
|
102
102
|
gestures: this.state.gestures,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render, screen } from '@testing-library/react'
|
|
3
|
+
|
|
4
|
+
import ViewerControls from './ViewerControls'
|
|
5
|
+
import ViewerByFile from './ViewerByFile'
|
|
6
|
+
|
|
7
|
+
jest.mock('../ViewersByFile/AudioViewer', () => () => <div>AudioViewer</div>)
|
|
8
|
+
jest.mock('../providers/EncryptedProvider', () => ({
|
|
9
|
+
useEncrypted: () => ({ url: 'random' })
|
|
10
|
+
}))
|
|
11
|
+
|
|
12
|
+
describe('ViewerControls', () => {
|
|
13
|
+
const file = {
|
|
14
|
+
_id: 'audio',
|
|
15
|
+
class: 'audio',
|
|
16
|
+
mime: 'audio/mp3',
|
|
17
|
+
name: 'sample.mp3'
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const setup = ({ children } = {}) => {
|
|
21
|
+
render(
|
|
22
|
+
<ViewerControls
|
|
23
|
+
file={file}
|
|
24
|
+
onClose={() => {}}
|
|
25
|
+
hasPrevious={false}
|
|
26
|
+
hasNext={false}
|
|
27
|
+
onPrevious={() => {}}
|
|
28
|
+
onNext={() => {}}
|
|
29
|
+
expanded={false}
|
|
30
|
+
toolbarProps={{
|
|
31
|
+
showToolbar: false,
|
|
32
|
+
showClose: false,
|
|
33
|
+
showFilePath: false,
|
|
34
|
+
toolbarRef: undefined
|
|
35
|
+
}}
|
|
36
|
+
showNavigation={false}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</ViewerControls>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
it('should only render children if they are ViewerByFile', () => {
|
|
44
|
+
setup({
|
|
45
|
+
children: [
|
|
46
|
+
undefined,
|
|
47
|
+
<div key="notViewer">not ViewerByFile</div>,
|
|
48
|
+
<ViewerByFile key="viewer" file={file} onClose={() => {}} />
|
|
49
|
+
]
|
|
50
|
+
})
|
|
51
|
+
expect(screen.queryByText('not ViewerByFile')).not.toBeInTheDocument()
|
|
52
|
+
expect(screen.getByText('AudioViewer')).toBeInTheDocument()
|
|
53
|
+
})
|
|
54
|
+
})
|
|
@@ -141,7 +141,9 @@ var ViewerControls = /*#__PURE__*/function (_Component) {
|
|
|
141
141
|
|
|
142
142
|
if (!children) return null;
|
|
143
143
|
return React.Children.map(children, function (child) {
|
|
144
|
-
|
|
144
|
+
var _child$type, _child$type2;
|
|
145
|
+
|
|
146
|
+
if ((child === null || child === void 0 ? void 0 : (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name) === 'ViewerByFile' || (child === null || child === void 0 ? void 0 : (_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.displayName) === 'ViewerByFile') {
|
|
145
147
|
return /*#__PURE__*/React.cloneElement(child, {
|
|
146
148
|
gestures: _this2.state.gestures,
|
|
147
149
|
gesturesRef: _this2.wrapped,
|