@synerise/ds-modal 0.17.0 → 0.17.1
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
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.17.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@0.17.0...@synerise/ds-modal@0.17.1) (2023-08-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-modal
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [0.17.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-modal@0.16.18...@synerise/ds-modal@0.17.0) (2023-08-20)
|
|
7
15
|
|
|
8
16
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default, buildModalFooter } from './Modal';
|
|
2
2
|
export { ModalTitle } from './Elements/ModalTitle';
|
|
3
3
|
export { ModalFooter } from './Elements/ModalFooter';
|
|
4
|
-
export
|
|
4
|
+
export { TitleContainer } from './Elements/ModalTitle';
|
|
5
5
|
export type { Props, ModalProps } from './Modal.types';
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { default, buildModalFooter } from './Modal';
|
|
2
2
|
export { ModalTitle } from './Elements/ModalTitle';
|
|
3
|
-
export { ModalFooter } from './Elements/ModalFooter';
|
|
3
|
+
export { ModalFooter } from './Elements/ModalFooter';
|
|
4
|
+
export { TitleContainer } from './Elements/ModalTitle';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-modal",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Modal UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "synerise/synerise-design",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@synerise/ds-utils": "^0.19.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "1f03e5affd1f22c9d3c7b4f1401887263d32d3d5"
|
|
49
49
|
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { screen } from '@testing-library/react';
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
4
|
-
import { renderWithProvider } from '@synerise/ds-utils/dist/testing';
|
|
5
|
-
import Button from '@synerise/ds-button';
|
|
6
|
-
import { ModalFooter } from './ModalFooter';
|
|
7
|
-
describe('ModalFooter', function () {
|
|
8
|
-
var onOkMock = jest.fn();
|
|
9
|
-
var onCancelMock = jest.fn();
|
|
10
|
-
|
|
11
|
-
var CustomButtonMock = function CustomButtonMock(_ref) {
|
|
12
|
-
var children = _ref.children,
|
|
13
|
-
onClick = _ref.onClick,
|
|
14
|
-
disabled = _ref.disabled;
|
|
15
|
-
return /*#__PURE__*/React.createElement(Button, {
|
|
16
|
-
onClick: onClick,
|
|
17
|
-
disabled: disabled
|
|
18
|
-
}, "Custom ", children);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
beforeEach(function () {
|
|
22
|
-
jest.clearAllMocks();
|
|
23
|
-
});
|
|
24
|
-
it('renders default cancel and apply buttons', function () {
|
|
25
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
|
|
26
|
-
onCancel: onCancelMock,
|
|
27
|
-
onOk: onOkMock
|
|
28
|
-
}));
|
|
29
|
-
var cancelButton = screen.getByText('Cancel');
|
|
30
|
-
var okButton = screen.getByText('Apply');
|
|
31
|
-
expect(cancelButton).toBeInTheDocument();
|
|
32
|
-
expect(okButton).toBeInTheDocument();
|
|
33
|
-
});
|
|
34
|
-
it('renders custom cancel and apply buttons', function () {
|
|
35
|
-
var customTexts = {
|
|
36
|
-
cancelButton: 'Custom Cancel',
|
|
37
|
-
okButton: 'Custom Apply'
|
|
38
|
-
};
|
|
39
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
|
|
40
|
-
onCancel: onCancelMock,
|
|
41
|
-
onOk: onOkMock,
|
|
42
|
-
texts: customTexts
|
|
43
|
-
}));
|
|
44
|
-
var cancelButton = screen.getByText('Custom Cancel');
|
|
45
|
-
var okButton = screen.getByText('Custom Apply');
|
|
46
|
-
expect(cancelButton).toBeInTheDocument();
|
|
47
|
-
expect(okButton).toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
it('calls onOk and onCancel callbacks when buttons are clicked', function () {
|
|
50
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
|
|
51
|
-
onCancel: onCancelMock,
|
|
52
|
-
onOk: onOkMock
|
|
53
|
-
}));
|
|
54
|
-
var cancelButton = screen.getByText('Cancel');
|
|
55
|
-
var okButton = screen.getByText('Apply');
|
|
56
|
-
userEvent.click(cancelButton);
|
|
57
|
-
expect(onCancelMock).toBeCalledTimes(1);
|
|
58
|
-
userEvent.click(okButton);
|
|
59
|
-
expect(onOkMock).toBeCalledTimes(1);
|
|
60
|
-
});
|
|
61
|
-
it('renders prefix, infix and suffix elements in the footer', function () {
|
|
62
|
-
var prefixNode = /*#__PURE__*/React.createElement("div", {
|
|
63
|
-
"data-testid": "prefix"
|
|
64
|
-
}, "Prefix Node");
|
|
65
|
-
var infixNode = /*#__PURE__*/React.createElement("div", {
|
|
66
|
-
"data-testid": "infix"
|
|
67
|
-
}, "Infix Node");
|
|
68
|
-
var suffixNode = /*#__PURE__*/React.createElement("div", {
|
|
69
|
-
"data-testid": "suffix"
|
|
70
|
-
}, "Suffix Node");
|
|
71
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
|
|
72
|
-
onCancel: onCancelMock,
|
|
73
|
-
onOk: onOkMock,
|
|
74
|
-
prefix: prefixNode,
|
|
75
|
-
suffix: suffixNode,
|
|
76
|
-
infix: infixNode
|
|
77
|
-
}));
|
|
78
|
-
var prefixElement = screen.getByTestId('prefix');
|
|
79
|
-
var infixElement = screen.getByTestId('infix');
|
|
80
|
-
var suffixElement = screen.getByTestId('suffix');
|
|
81
|
-
expect(prefixElement).toBeInTheDocument();
|
|
82
|
-
expect(infixElement).toBeInTheDocument();
|
|
83
|
-
expect(suffixElement).toBeInTheDocument();
|
|
84
|
-
});
|
|
85
|
-
it('renders custom DSButton component for cancel and apply buttons', function () {
|
|
86
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalFooter, {
|
|
87
|
-
onCancel: onCancelMock,
|
|
88
|
-
onOk: onOkMock,
|
|
89
|
-
CustomFooterButton: CustomButtonMock
|
|
90
|
-
}));
|
|
91
|
-
var cancelButton = screen.getByText('Custom Cancel');
|
|
92
|
-
var okButton = screen.getByText('Custom Apply');
|
|
93
|
-
expect(cancelButton).toHaveTextContent('Custom Cancel');
|
|
94
|
-
expect(okButton).toHaveTextContent('Custom Apply');
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { renderWithProvider } from '@synerise/ds-utils/dist/testing';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import { ModalTitle } from './ModalTitle';
|
|
6
|
-
describe('ModalTitle', function () {
|
|
7
|
-
var onCancelMock = jest.fn();
|
|
8
|
-
var title = 'Test Title';
|
|
9
|
-
var description = 'Test Description';
|
|
10
|
-
beforeEach(function () {
|
|
11
|
-
jest.clearAllMocks();
|
|
12
|
-
});
|
|
13
|
-
it('should render title and description when props are provided', function () {
|
|
14
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
15
|
-
title: title,
|
|
16
|
-
description: description
|
|
17
|
-
}));
|
|
18
|
-
var titleElement = screen.getByText(title);
|
|
19
|
-
var descriptionElement = screen.getByText(description);
|
|
20
|
-
expect(titleElement).toBeInTheDocument();
|
|
21
|
-
expect(descriptionElement).toBeInTheDocument();
|
|
22
|
-
});
|
|
23
|
-
it('should render close button when blank is true and onCancel is provided', function () {
|
|
24
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
25
|
-
blank: true,
|
|
26
|
-
onCancel: onCancelMock
|
|
27
|
-
}));
|
|
28
|
-
var closeButton = screen.getByTestId('modal-close');
|
|
29
|
-
expect(closeButton).toBeInTheDocument();
|
|
30
|
-
});
|
|
31
|
-
it('should call onCancel when the close button is clicked', function () {
|
|
32
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
33
|
-
blank: true,
|
|
34
|
-
onCancel: onCancelMock
|
|
35
|
-
}));
|
|
36
|
-
var closeButton = screen.getByTestId('modal-close');
|
|
37
|
-
userEvent.click(closeButton);
|
|
38
|
-
expect(onCancelMock).toHaveBeenCalled();
|
|
39
|
-
});
|
|
40
|
-
it('should not render close button when blank is true but onCancel is not provided', function () {
|
|
41
|
-
render( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
42
|
-
blank: true
|
|
43
|
-
}));
|
|
44
|
-
var closeButton = screen.queryByTestId('modal-close');
|
|
45
|
-
expect(closeButton).not.toBeInTheDocument();
|
|
46
|
-
});
|
|
47
|
-
it('should render headerActions when provided', function () {
|
|
48
|
-
// eslint-disable-next-line react/button-has-type
|
|
49
|
-
var headerActions = /*#__PURE__*/React.createElement("button", {
|
|
50
|
-
onClick: jest.fn()
|
|
51
|
-
}, "Test Action");
|
|
52
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
53
|
-
title: title,
|
|
54
|
-
headerActions: headerActions
|
|
55
|
-
}));
|
|
56
|
-
var headerActionsElement = screen.getByText('Test Action');
|
|
57
|
-
expect(headerActionsElement).toBeInTheDocument();
|
|
58
|
-
});
|
|
59
|
-
it('should not render headerActions when not provided', function () {
|
|
60
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
61
|
-
title: title
|
|
62
|
-
}));
|
|
63
|
-
var headerActionsElement = screen.queryByText('Test Action');
|
|
64
|
-
expect(headerActionsElement).not.toBeInTheDocument();
|
|
65
|
-
});
|
|
66
|
-
it('should render custom title container style when provided', function () {
|
|
67
|
-
var customStyle = {
|
|
68
|
-
backgroundColor: 'red'
|
|
69
|
-
};
|
|
70
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
71
|
-
title: title,
|
|
72
|
-
titleContainerStyle: customStyle
|
|
73
|
-
}));
|
|
74
|
-
var titleContainer = screen.getByTestId('modal-title');
|
|
75
|
-
expect(titleContainer).toHaveStyle(customStyle);
|
|
76
|
-
});
|
|
77
|
-
it('should not render description when description prop is not provided', function () {
|
|
78
|
-
renderWithProvider( /*#__PURE__*/React.createElement(ModalTitle, {
|
|
79
|
-
title: "Test Title"
|
|
80
|
-
}));
|
|
81
|
-
var descriptionElement = screen.queryByText('Test Description');
|
|
82
|
-
expect(descriptionElement).not.toBeInTheDocument();
|
|
83
|
-
});
|
|
84
|
-
});
|
package/dist/Modal.spec.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { screen } from '@testing-library/react';
|
|
3
|
-
import { renderWithProvider } from '@synerise/ds-utils/dist/testing';
|
|
4
|
-
import Modal from './Modal';
|
|
5
|
-
describe('Modal', function () {
|
|
6
|
-
var titleMock = 'Test Title';
|
|
7
|
-
var descriptionMock = 'Test Description';
|
|
8
|
-
beforeEach(function () {
|
|
9
|
-
jest.clearAllMocks();
|
|
10
|
-
});
|
|
11
|
-
it('should not render modal if there is no visible prop or visible is false', function () {
|
|
12
|
-
renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
|
|
13
|
-
title: titleMock,
|
|
14
|
-
description: descriptionMock
|
|
15
|
-
}));
|
|
16
|
-
var modalDialog = screen.queryByRole('document');
|
|
17
|
-
expect(modalDialog).not.toBeInTheDocument();
|
|
18
|
-
});
|
|
19
|
-
it('should render title, description, and blank correctly', function () {
|
|
20
|
-
renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
|
|
21
|
-
title: titleMock,
|
|
22
|
-
description: descriptionMock,
|
|
23
|
-
visible: true
|
|
24
|
-
}));
|
|
25
|
-
var titleElement = screen.getByText(titleMock);
|
|
26
|
-
var descriptionElement = screen.getByText(descriptionMock);
|
|
27
|
-
expect(titleElement).toBeInTheDocument();
|
|
28
|
-
expect(descriptionElement).toBeInTheDocument();
|
|
29
|
-
});
|
|
30
|
-
it('should not render title and description when blank, title and description is false', function () {
|
|
31
|
-
renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
|
|
32
|
-
visible: true
|
|
33
|
-
}));
|
|
34
|
-
var titleElement = screen.queryByText(titleMock);
|
|
35
|
-
var descriptionElement = screen.queryByText(descriptionMock);
|
|
36
|
-
var closeButton = screen.queryByTestId('modal-close');
|
|
37
|
-
expect(titleElement).not.toBeInTheDocument();
|
|
38
|
-
expect(descriptionElement).not.toBeInTheDocument();
|
|
39
|
-
expect(closeButton).not.toBeInTheDocument();
|
|
40
|
-
});
|
|
41
|
-
it('should render headerActions when provided', function () {
|
|
42
|
-
// eslint-disable-next-line react/button-has-type
|
|
43
|
-
var headerActions = /*#__PURE__*/React.createElement("button", {
|
|
44
|
-
onClick: jest.fn()
|
|
45
|
-
}, "Test Action");
|
|
46
|
-
renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
|
|
47
|
-
title: titleMock,
|
|
48
|
-
headerActions: headerActions,
|
|
49
|
-
visible: true
|
|
50
|
-
}));
|
|
51
|
-
var headerActionsElement = screen.getByText('Test Action');
|
|
52
|
-
expect(headerActionsElement).toBeInTheDocument();
|
|
53
|
-
});
|
|
54
|
-
it('should render custom size correctly', function () {
|
|
55
|
-
renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
|
|
56
|
-
title: "Test Title",
|
|
57
|
-
size: "medium",
|
|
58
|
-
visible: true
|
|
59
|
-
}));
|
|
60
|
-
var modalDialog = screen.getByRole('document');
|
|
61
|
-
expect(modalDialog).toHaveStyle({
|
|
62
|
-
width: '792px'
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
it('should show custom footer if its in props', function () {
|
|
66
|
-
renderWithProvider( /*#__PURE__*/React.createElement(Modal, {
|
|
67
|
-
footer: /*#__PURE__*/React.createElement("div", null, "Custom Footer"),
|
|
68
|
-
visible: true
|
|
69
|
-
}));
|
|
70
|
-
var customFooter = screen.getByText('Custom Footer');
|
|
71
|
-
var defaultFooter = screen.queryByTestId('modal-footer');
|
|
72
|
-
expect(customFooter).toBeInTheDocument();
|
|
73
|
-
expect(defaultFooter).not.toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
});
|