cozy-sharing 17.0.0 → 19.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/SharingProvider.spec.js +84 -80
  3. package/dist/components/Recipient/LinkRecipientPermissions.js +18 -129
  4. package/dist/components/Recipient/actions/editPermissionLink.js +71 -0
  5. package/dist/components/Recipient/actions/readOnlyPermissionLink.js +63 -0
  6. package/dist/components/ShareByLink.js +45 -185
  7. package/dist/components/ShareDialogCozyToCozy.js +2 -6
  8. package/dist/components/ShareDialogOnlyByLink.js +2 -8
  9. package/dist/components/ShareDialogTwoStepsConfirmationContainer.js +1 -3
  10. package/dist/components/ShareModal/EditableSharingModal.js +1 -7
  11. package/dist/components/ShareModal/EditableSharingModal.spec.js +49 -52
  12. package/dist/components/ShareModal/SharingDetailsModal.js +1 -1
  13. package/dist/components/ShareModal.js +0 -12
  14. package/dist/components/ShareRestrictionModal/BoxDate.js +77 -0
  15. package/dist/components/ShareRestrictionModal/BoxEditingRights.js +83 -0
  16. package/dist/components/ShareRestrictionModal/BoxPassword.js +138 -0
  17. package/dist/components/ShareRestrictionModal/ShareRestrictionContentModal.js +94 -0
  18. package/dist/components/ShareRestrictionModal/ShareRestrictionModal.js +260 -0
  19. package/dist/components/ShareRestrictionModal/helpers.js +275 -0
  20. package/dist/components/ShareRestrictionModal/helpers.spec.js +110 -0
  21. package/dist/components/SharedStatus.spec.js +20 -21
  22. package/dist/components/WhoHasAccess.js +1 -5
  23. package/jest.config.js +8 -3
  24. package/jestHelpers/setup.js +1 -8
  25. package/locales/en.json +28 -0
  26. package/locales/fr.json +29 -0
  27. package/package.json +13 -11
  28. package/src/SharingProvider.spec.jsx +88 -88
  29. package/src/components/Recipient/LinkRecipientPermissions.jsx +28 -137
  30. package/src/components/Recipient/actions/editPermissionLink.js +63 -0
  31. package/src/components/Recipient/actions/readOnlyPermissionLink.js +59 -0
  32. package/src/components/ShareByLink.jsx +20 -96
  33. package/src/components/ShareDialogCozyToCozy.jsx +1 -5
  34. package/src/components/ShareDialogOnlyByLink.jsx +0 -6
  35. package/src/components/ShareDialogTwoStepsConfirmationContainer.jsx +0 -2
  36. package/src/components/ShareModal/EditableSharingModal.jsx +1 -7
  37. package/src/components/ShareModal/EditableSharingModal.spec.jsx +50 -44
  38. package/src/components/ShareModal/SharingDetailsModal.jsx +1 -1
  39. package/src/components/ShareModal.jsx +0 -12
  40. package/src/components/ShareRestrictionModal/BoxDate.jsx +76 -0
  41. package/src/components/ShareRestrictionModal/BoxEditingRights.jsx +91 -0
  42. package/src/components/ShareRestrictionModal/BoxPassword.jsx +112 -0
  43. package/src/components/ShareRestrictionModal/ShareRestrictionContentModal.jsx +102 -0
  44. package/src/components/ShareRestrictionModal/ShareRestrictionModal.jsx +177 -0
  45. package/src/components/ShareRestrictionModal/helpers.js +193 -0
  46. package/src/components/ShareRestrictionModal/helpers.spec.js +78 -0
  47. package/src/components/SharedStatus.spec.js +32 -31
  48. package/src/components/WhoHasAccess.jsx +1 -5
  49. package/src/components/__snapshots__/SharedStatus.spec.js.snap +59 -129
  50. package/dist/RefreshableSharings.spec.js +0 -40
  51. package/dist/components/EditLinkPermissionDialog.js +0 -72
  52. package/dist/components/EditLinkPermissionDialog.spec.js +0 -48
  53. package/src/RefreshableSharings.spec.jsx +0 -43
  54. package/src/components/EditLinkPermissionDialog.jsx +0 -89
  55. package/src/components/EditLinkPermissionDialog.spec.jsx +0 -53
@@ -1,47 +1,48 @@
1
- import { mount } from 'enzyme'
1
+ import { render } from '@testing-library/react'
2
2
  import React from 'react'
3
3
 
4
4
  import { SharedStatus } from './SharedStatus'
5
5
  import AppLike from '../../test/AppLike'
6
- describe('SharedStatus component', () => {
7
- const WrappingComponent = ({ children }) => <AppLike>{children}</AppLike>
8
6
 
7
+ describe('SharedStatus component', () => {
9
8
  it('should just render a span if no sharing', () => {
10
- const component = mount(<SharedStatus docId="1" recipients={[]} />, {
11
- wrappingComponent: WrappingComponent
12
- })
13
- expect(component).toMatchSnapshot()
9
+ const { container } = render(
10
+ <AppLike>
11
+ <SharedStatus docId="1" recipients={[]} />
12
+ </AppLike>
13
+ )
14
+ expect(container).toMatchSnapshot()
14
15
  })
15
16
 
16
17
  it('should have the right display if there is several recipients', () => {
17
- const component = mount(
18
- <SharedStatus
19
- docId="1"
20
- recipients={[
21
- {
22
- _id: 1,
23
- name: '1'
24
- },
25
- {
26
- _id: 2,
27
- name: '2'
28
- }
29
- ]}
30
- />,
31
- {
32
- wrappingComponent: WrappingComponent
33
- }
18
+ const { container, getByText } = render(
19
+ <AppLike>
20
+ <SharedStatus
21
+ docId="1"
22
+ recipients={[
23
+ {
24
+ _id: 1,
25
+ name: '1'
26
+ },
27
+ {
28
+ _id: 2,
29
+ name: '2'
30
+ }
31
+ ]}
32
+ />
33
+ </AppLike>
34
34
  )
35
- expect(component).toMatchSnapshot()
35
+ expect(container).toMatchSnapshot()
36
+ expect(getByText('2 members')).toBeTruthy()
36
37
  })
37
38
 
38
39
  it('should display the link if there is a link', () => {
39
- const component = mount(
40
- <SharedStatus docId="1" recipients={[]} link={true} />,
41
- {
42
- wrappingComponent: WrappingComponent
43
- }
40
+ const { container, getByText } = render(
41
+ <AppLike>
42
+ <SharedStatus docId="1" recipients={[]} link={true} />
43
+ </AppLike>
44
44
  )
45
- expect(component).toMatchSnapshot()
45
+ expect(container).toMatchSnapshot()
46
+ expect(getByText('Shared by link')).toBeTruthy()
46
47
  })
47
48
  })
@@ -37,9 +37,7 @@ const WhoHasAccess = ({
37
37
  onRevokeSelf,
38
38
  verifyRecipient,
39
39
  link,
40
- permissions,
41
- onUpdateShareLinkPermissions,
42
- onRevokeLink
40
+ permissions
43
41
  }) => {
44
42
  const previousLink = usePrevious(link)
45
43
  const linkHasBeenJustCreated = link && previousLink === null
@@ -58,8 +56,6 @@ const WhoHasAccess = ({
58
56
  onRevokeSelf={onRevokeSelf}
59
57
  link={link}
60
58
  permissions={permissions}
61
- onChangePermissions={onUpdateShareLinkPermissions}
62
- onDisable={onRevokeLink}
63
59
  fadeIn={linkHasBeenJustCreated}
64
60
  />
65
61
  )}
@@ -1,41 +1,23 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`SharedStatus component should display the link if there is a link 1`] = `
4
- <SharedStatus
5
- docId="1"
6
- link={true}
7
- recipients={Array []}
8
- >
9
- <span
10
- className="shared-status"
4
+ <div>
5
+ <div
6
+ class="CozyTheme--light-normal u-dc"
11
7
  >
12
- <LinkIcon
13
- data-for="linkfor1"
14
- data-tip={true}
15
- height="16"
16
- style={
17
- Object {
18
- "fill": "var(--iconTextColor)",
19
- }
20
- }
21
- viewBox="0 0 16 16"
22
- width="16"
23
- xmlns="http://www.w3.org/2000/svg"
24
- xmlnsXlink="http://www.w3.org/1999/xlink"
8
+ <span
9
+ class="shared-status"
25
10
  >
26
11
  <svg
12
+ currentItem="false"
27
13
  data-for="linkfor1"
28
- data-tip={true}
14
+ data-tip="true"
29
15
  height="16"
30
- style={
31
- Object {
32
- "fill": "var(--iconTextColor)",
33
- }
34
- }
16
+ style="fill: var(--iconTextColor);"
35
17
  viewBox="0 0 16 16"
36
18
  width="16"
37
19
  xmlns="http://www.w3.org/2000/svg"
38
- xmlnsXlink="http://www.w3.org/1999/xlink"
20
+ xmlns:xlink="http://www.w3.org/1999/xlink"
39
21
  >
40
22
  <defs>
41
23
  <path
@@ -44,121 +26,69 @@ exports[`SharedStatus component should display the link if there is a link 1`] =
44
26
  />
45
27
  </defs>
46
28
  <use
47
- fillRule="nonzero"
48
- xlinkHref="#link-1-path-1"
29
+ fill-rule="nonzero"
30
+ xlink:href="#link-1-path-1"
49
31
  />
50
32
  </svg>
51
- </LinkIcon>
52
- <SharingTooltip
53
- id="linkfor1"
54
- >
55
- <ReactTooltip
56
- className="shared-tooltip"
57
- clickable={false}
58
- effect="solid"
33
+ <div
34
+ class="__react_component_tooltip place-bottom type-dark "
35
+ data-id="tooltip"
59
36
  id="linkfor1"
60
- insecure={true}
61
- place="bottom"
62
- resizeHide={true}
63
- wrapper="div"
64
37
  >
65
- <div
66
- className="__react_component_tooltip place-bottom type-dark "
67
- data-id="tooltip"
68
- id="linkfor1"
69
- >
70
- <span>
71
- Shared by link
72
- </span>
73
- </div>
74
- </ReactTooltip>
75
- </SharingTooltip>
76
- </span>
77
- </SharedStatus>
38
+ <span>
39
+ Shared by link
40
+ </span>
41
+ </div>
42
+ </span>
43
+ </div>
44
+ </div>
78
45
  `;
79
46
 
80
47
  exports[`SharedStatus component should have the right display if there is several recipients 1`] = `
81
- <SharedStatus
82
- docId="1"
83
- recipients={
84
- Array [
85
- Object {
86
- "_id": 1,
87
- "name": "1",
88
- },
89
- Object {
90
- "_id": 2,
91
- "name": "2",
92
- },
93
- ]
94
- }
95
- >
96
- <span
97
- className="shared-status"
48
+ <div>
49
+ <div
50
+ class="CozyTheme--light-normal u-dc"
98
51
  >
99
- <a
100
- className="shared-status-label"
101
- data-for="members1"
102
- data-tip={true}
103
- >
104
- 2 members
105
- </a>
106
- <SharingTooltip
107
- id="members1"
52
+ <span
53
+ class="shared-status"
108
54
  >
109
- <ReactTooltip
110
- className="shared-tooltip"
111
- clickable={false}
112
- effect="solid"
55
+ <a
56
+ class="shared-status-label"
57
+ currentitem="false"
58
+ data-for="members1"
59
+ data-tip="true"
60
+ >
61
+ 2 members
62
+ </a>
63
+ <div
64
+ class="__react_component_tooltip place-bottom type-dark "
65
+ data-id="tooltip"
113
66
  id="members1"
114
- insecure={true}
115
- place="bottom"
116
- resizeHide={true}
117
- wrapper="div"
118
67
  >
119
- <div
120
- className="__react_component_tooltip place-bottom type-dark "
121
- data-id="tooltip"
122
- id="members1"
68
+ <ul
69
+ class="shared-tooltip-list"
123
70
  >
124
- <TooltipRecipientList
125
- cutoff={4}
126
- recipientNames={
127
- Array [
128
- "1",
129
- "2",
130
- ]
131
- }
132
- >
133
- <ul
134
- className="shared-tooltip-list"
135
- >
136
- <li
137
- key="key_name_1_0"
138
- >
139
- 1
140
- </li>
141
- <li
142
- key="key_name_2_1"
143
- >
144
- 2
145
- </li>
146
- </ul>
147
- </TooltipRecipientList>
148
- </div>
149
- </ReactTooltip>
150
- </SharingTooltip>
151
- </span>
152
- </SharedStatus>
71
+ <li>
72
+ 1
73
+ </li>
74
+ <li>
75
+ 2
76
+ </li>
77
+ </ul>
78
+ </div>
79
+ </span>
80
+ </div>
81
+ </div>
153
82
  `;
154
83
 
155
84
  exports[`SharedStatus component should just render a span if no sharing 1`] = `
156
- <SharedStatus
157
- docId="1"
158
- recipients={Array []}
159
- >
160
- <span
161
- className="shared-status"
162
- />
163
- </SharedStatus>
85
+ <div>
86
+ <div
87
+ class="CozyTheme--light-normal u-dc"
88
+ >
89
+ <span
90
+ class="shared-status"
91
+ />
92
+ </div>
93
+ </div>
164
94
  `;
@@ -1,40 +0,0 @@
1
- import { mount } from 'enzyme';
2
- import React from 'react';
3
- import { createMockClient } from 'cozy-client';
4
- import { RefreshableSharings } from './RefreshableSharings';
5
- import { SharingProvider } from './SharingProvider';
6
- import AppLike from '../test/AppLike';
7
-
8
- var DumbComponent = function DumbComponent() {
9
- return /*#__PURE__*/React.createElement("div", null, "test ");
10
- };
11
-
12
- var AppWrapper = function AppWrapper(_ref) {
13
- var children = _ref.children,
14
- client = _ref.client;
15
- return /*#__PURE__*/React.createElement(AppLike, {
16
- client: client
17
- }, /*#__PURE__*/React.createElement(SharingProvider, {
18
- client: client
19
- }, children));
20
- };
21
-
22
- describe('RefreshableSharings', function () {
23
- it('should test', function () {
24
- var client = createMockClient({});
25
- var component = mount( /*#__PURE__*/React.createElement(AppWrapper, {
26
- client: client
27
- }, /*#__PURE__*/React.createElement(RefreshableSharings, null, function (_ref2) {
28
- var refresh = _ref2.refresh;
29
- return /*#__PURE__*/React.createElement(DumbComponent, {
30
- client: client,
31
- t: function t(x) {
32
- return x;
33
- },
34
- refreshSharings: refresh
35
- });
36
- })));
37
- var refreshMethod = component.find(DumbComponent).prop('refreshSharings');
38
- expect(typeof refreshMethod).toBe('function');
39
- });
40
- });
@@ -1,72 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import PropTypes from 'prop-types';
3
- import React, { useState } from 'react';
4
- import Button from 'cozy-ui/transpiled/react/Buttons';
5
- import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs';
6
- import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel';
7
- import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup';
8
- import Radio from 'cozy-ui/transpiled/react/Radios';
9
- import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n';
10
-
11
- var EditLinkPermissionDialog = function EditLinkPermissionDialog(_ref) {
12
- var open = _ref.open,
13
- onClose = _ref.onClose,
14
- document = _ref.document,
15
- onPermissionsSelected = _ref.onPermissionsSelected;
16
-
17
- var _useI18n = useI18n(),
18
- t = _useI18n.t;
19
-
20
- var _useState = useState(true),
21
- _useState2 = _slicedToArray(_useState, 2),
22
- isReadOnlyPermissions = _useState2[0],
23
- setIsReadOnlyPermissions = _useState2[1];
24
-
25
- var onChange = function onChange(event) {
26
- setIsReadOnlyPermissions(event.target.value === 'true');
27
- };
28
-
29
- var onConfirm = function onConfirm() {
30
- var verbs = isReadOnlyPermissions ? ['GET'] : ['GET', 'POST', 'PUT', 'PATCH'];
31
- onPermissionsSelected({
32
- verbs: verbs
33
- });
34
- onClose();
35
- };
36
-
37
- return /*#__PURE__*/React.createElement(ConfirmDialog, {
38
- open: open,
39
- onClose: onClose,
40
- title: t('Share.permissionLink.title'),
41
- content: /*#__PURE__*/React.createElement(RadioGroup, {
42
- "aria-label": "radio",
43
- value: isReadOnlyPermissions.toString(),
44
- onChange: onChange
45
- }, /*#__PURE__*/React.createElement(FormControlLabel, {
46
- value: "true",
47
- label: (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.seeFolder") : t("Share.permissionLink.seeFile"),
48
- control: /*#__PURE__*/React.createElement(Radio, null)
49
- }), /*#__PURE__*/React.createElement(FormControlLabel, {
50
- value: "false",
51
- label: (document === null || document === void 0 ? void 0 : document.type) === 'directory' ? t("Share.permissionLink.modifyFolder") : t("Share.permissionLink.modifyFile"),
52
- control: /*#__PURE__*/React.createElement(Radio, null)
53
- })),
54
- actions: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
55
- variant: "secondary",
56
- label: t('Share.permissionLink.cancel'),
57
- onClick: onClose
58
- }), /*#__PURE__*/React.createElement(Button, {
59
- variant: "primary",
60
- label: t('Share.permissionLink.confirm'),
61
- onClick: onConfirm
62
- }))
63
- });
64
- };
65
-
66
- EditLinkPermissionDialog.propTypes = {
67
- open: PropTypes.bool.isRequired,
68
- onClose: PropTypes.func.isRequired,
69
- document: PropTypes.object.isRequired,
70
- onPermissionsSelected: PropTypes.func.isRequired
71
- };
72
- export default EditLinkPermissionDialog;
@@ -1,48 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- import { render, fireEvent } from '@testing-library/react';
3
- import React from 'react';
4
- import { createMockClient } from 'cozy-client';
5
- import EditLinkPermissionDialog from './EditLinkPermissionDialog';
6
- import AppLike from '../../test/AppLike';
7
- describe('EditLinkPermissionDialog', function () {
8
- var client = createMockClient({});
9
-
10
- var setup = function setup(props) {
11
- return render( /*#__PURE__*/React.createElement(AppLike, {
12
- client: client
13
- }, /*#__PURE__*/React.createElement(EditLinkPermissionDialog, _extends({
14
- open: true,
15
- onClose: function onClose() {}
16
- }, props))));
17
- };
18
-
19
- it('should select read permissions', function () {
20
- var onPermissionsSelected = jest.fn();
21
- var props = {
22
- onPermissionsSelected: onPermissionsSelected
23
- };
24
-
25
- var _setup = setup(props),
26
- getByText = _setup.getByText;
27
-
28
- fireEvent.click(getByText('OK'));
29
- expect(onPermissionsSelected).toHaveBeenCalledWith({
30
- verbs: ['GET']
31
- });
32
- });
33
- it('should select write permissions', function () {
34
- var onPermissionsSelected = jest.fn();
35
- var props = {
36
- onPermissionsSelected: onPermissionsSelected
37
- };
38
-
39
- var _setup2 = setup(props),
40
- getByText = _setup2.getByText;
41
-
42
- fireEvent.click(getByText('Modify file'));
43
- fireEvent.click(getByText('OK'));
44
- expect(onPermissionsSelected).toHaveBeenCalledWith({
45
- verbs: ['GET', 'POST', 'PUT', 'PATCH']
46
- });
47
- });
48
- });
@@ -1,43 +0,0 @@
1
- import { mount } from 'enzyme'
2
- import React from 'react'
3
-
4
- import { createMockClient } from 'cozy-client'
5
-
6
- import { RefreshableSharings } from './RefreshableSharings'
7
- import { SharingProvider } from './SharingProvider'
8
- import AppLike from '../test/AppLike'
9
-
10
- const DumbComponent = () => {
11
- return <div>test </div>
12
- }
13
-
14
- const AppWrapper = ({ children, client }) => {
15
- return (
16
- <AppLike client={client}>
17
- <SharingProvider client={client}>{children}</SharingProvider>
18
- </AppLike>
19
- )
20
- }
21
-
22
- describe('RefreshableSharings', () => {
23
- it('should test', () => {
24
- const client = createMockClient({})
25
-
26
- const component = mount(
27
- <AppWrapper client={client}>
28
- <RefreshableSharings>
29
- {({ refresh }) => (
30
- <DumbComponent
31
- client={client}
32
- t={x => x}
33
- refreshSharings={refresh}
34
- />
35
- )}
36
- </RefreshableSharings>
37
- </AppWrapper>
38
- )
39
- const refreshMethod = component.find(DumbComponent).prop('refreshSharings')
40
-
41
- expect(typeof refreshMethod).toBe('function')
42
- })
43
- })
@@ -1,89 +0,0 @@
1
- import PropTypes from 'prop-types'
2
- import React, { useState } from 'react'
3
-
4
- import Button from 'cozy-ui/transpiled/react/Buttons'
5
- import { ConfirmDialog } from 'cozy-ui/transpiled/react/CozyDialogs'
6
- import FormControlLabel from 'cozy-ui/transpiled/react/FormControlLabel'
7
- import RadioGroup from 'cozy-ui/transpiled/react/RadioGroup'
8
- import Radio from 'cozy-ui/transpiled/react/Radios'
9
- import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
10
-
11
- const EditLinkPermissionDialog = ({
12
- open,
13
- onClose,
14
- document,
15
- onPermissionsSelected
16
- }) => {
17
- const { t } = useI18n()
18
-
19
- const [isReadOnlyPermissions, setIsReadOnlyPermissions] = useState(true)
20
-
21
- const onChange = event => {
22
- setIsReadOnlyPermissions(event.target.value === 'true')
23
- }
24
-
25
- const onConfirm = () => {
26
- const verbs = isReadOnlyPermissions
27
- ? ['GET']
28
- : ['GET', 'POST', 'PUT', 'PATCH']
29
- onPermissionsSelected({ verbs })
30
- onClose()
31
- }
32
-
33
- return (
34
- <ConfirmDialog
35
- open={open}
36
- onClose={onClose}
37
- title={t('Share.permissionLink.title')}
38
- content={
39
- <RadioGroup
40
- aria-label="radio"
41
- value={isReadOnlyPermissions.toString()}
42
- onChange={onChange}
43
- >
44
- <FormControlLabel
45
- value="true"
46
- label={
47
- document?.type === 'directory'
48
- ? t(`Share.permissionLink.seeFolder`)
49
- : t(`Share.permissionLink.seeFile`)
50
- }
51
- control={<Radio />}
52
- />
53
- <FormControlLabel
54
- value="false"
55
- label={
56
- document?.type === 'directory'
57
- ? t(`Share.permissionLink.modifyFolder`)
58
- : t(`Share.permissionLink.modifyFile`)
59
- }
60
- control={<Radio />}
61
- />
62
- </RadioGroup>
63
- }
64
- actions={
65
- <>
66
- <Button
67
- variant="secondary"
68
- label={t('Share.permissionLink.cancel')}
69
- onClick={onClose}
70
- />
71
- <Button
72
- variant="primary"
73
- label={t('Share.permissionLink.confirm')}
74
- onClick={onConfirm}
75
- />
76
- </>
77
- }
78
- />
79
- )
80
- }
81
-
82
- EditLinkPermissionDialog.propTypes = {
83
- open: PropTypes.bool.isRequired,
84
- onClose: PropTypes.func.isRequired,
85
- document: PropTypes.object.isRequired,
86
- onPermissionsSelected: PropTypes.func.isRequired
87
- }
88
-
89
- export default EditLinkPermissionDialog
@@ -1,53 +0,0 @@
1
- import { render, fireEvent } from '@testing-library/react'
2
- import React from 'react'
3
-
4
- import { createMockClient } from 'cozy-client'
5
-
6
- import EditLinkPermissionDialog from './EditLinkPermissionDialog'
7
- import AppLike from '../../test/AppLike'
8
-
9
- describe('EditLinkPermissionDialog', () => {
10
- const client = createMockClient({})
11
-
12
- const setup = props => {
13
- return render(
14
- <AppLike client={client}>
15
- <EditLinkPermissionDialog open onClose={() => {}} {...props} />
16
- </AppLike>
17
- )
18
- }
19
-
20
- it('should select read permissions', () => {
21
- const onPermissionsSelected = jest.fn()
22
-
23
- const props = {
24
- onPermissionsSelected
25
- }
26
-
27
- const { getByText } = setup(props)
28
-
29
- fireEvent.click(getByText('OK'))
30
-
31
- expect(onPermissionsSelected).toHaveBeenCalledWith({
32
- verbs: ['GET']
33
- })
34
- })
35
-
36
- it('should select write permissions', () => {
37
- const onPermissionsSelected = jest.fn()
38
-
39
- const props = {
40
- onPermissionsSelected
41
- }
42
-
43
- const { getByText } = setup(props)
44
-
45
- fireEvent.click(getByText('Modify file'))
46
-
47
- fireEvent.click(getByText('OK'))
48
-
49
- expect(onPermissionsSelected).toHaveBeenCalledWith({
50
- verbs: ['GET', 'POST', 'PUT', 'PATCH']
51
- })
52
- })
53
- })