@laerdal/life-react-components 1.3.1-dev.3.full → 1.3.1-dev.4

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 (27) hide show
  1. package/dist/esm/Accordion/ContentAccordion.js +238 -0
  2. package/dist/esm/Accordion/ContentAccordion.js.map +1 -0
  3. package/dist/esm/Accordion/__tests__/ContetnAccordion.test.js +137 -0
  4. package/dist/esm/Accordion/__tests__/ContetnAccordion.test.js.map +1 -0
  5. package/dist/esm/Accordion/index.js +1 -0
  6. package/dist/esm/Accordion/index.js.map +1 -1
  7. package/dist/js/Accordion/ContentAccordion.d.ts +18 -0
  8. package/dist/js/Accordion/ContentAccordion.js +151 -0
  9. package/dist/js/Accordion/ContentAccordion.js.map +1 -0
  10. package/dist/js/Accordion/__tests__/ContetnAccordion.test.js +151 -0
  11. package/dist/js/Accordion/__tests__/ContetnAccordion.test.js.map +1 -0
  12. package/dist/js/Accordion/index.d.ts +1 -0
  13. package/dist/js/Accordion/index.js +8 -0
  14. package/dist/js/Accordion/index.js.map +1 -1
  15. package/dist/umd/Accordion/ContentAccordion.js +266 -0
  16. package/dist/umd/Accordion/ContentAccordion.js.map +1 -0
  17. package/dist/umd/Accordion/__tests__/ContetnAccordion.test.js +165 -0
  18. package/dist/umd/Accordion/__tests__/ContetnAccordion.test.js.map +1 -0
  19. package/dist/umd/Accordion/index.js +10 -4
  20. package/dist/umd/Accordion/index.js.map +1 -1
  21. package/package.json +1 -1
  22. package/dist/esm/Modals/__tests__/Modal.test.js +0 -154
  23. package/dist/esm/Modals/__tests__/Modal.test.js.map +0 -1
  24. package/dist/js/Modals/__tests__/Modal.test.js +0 -231
  25. package/dist/js/Modals/__tests__/Modal.test.js.map +0 -1
  26. package/dist/umd/Modals/__tests__/Modal.test.js +0 -173
  27. package/dist/umd/Modals/__tests__/Modal.test.js.map +0 -1
@@ -0,0 +1,165 @@
1
+ (function (global, factory) {
2
+ if (typeof define === "function" && define.amd) {
3
+ define(["react", "../ContentAccordion", "@testing-library/react", "../../types"], factory);
4
+ } else if (typeof exports !== "undefined") {
5
+ factory(require("react"), require("../ContentAccordion"), require("@testing-library/react"), require("../../types"));
6
+ } else {
7
+ var mod = {
8
+ exports: {}
9
+ };
10
+ factory(global.react, global.ContentAccordion, global.react, global.types);
11
+ global.undefined = mod.exports;
12
+ }
13
+ })(this, function (_react, _ContentAccordion, _react3, _types) {
14
+ "use strict";
15
+
16
+ var _react2 = _interopRequireDefault(_react);
17
+
18
+ var _ContentAccordion2 = _interopRequireDefault(_ContentAccordion);
19
+
20
+ function _interopRequireDefault(obj) {
21
+ return obj && obj.__esModule ? obj : {
22
+ default: obj
23
+ };
24
+ }
25
+
26
+ describe('ContentAccordion', () => {
27
+ const contentAccordionItemsWithBody = [{
28
+ key: '1',
29
+ title: 'Item 1',
30
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
31
+ }, {
32
+ key: '2',
33
+ title: 'Item 2',
34
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
35
+ active: true
36
+ }, {
37
+ key: '3',
38
+ title: 'Item 3',
39
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
40
+ disabled: true
41
+ }, {
42
+ key: '4',
43
+ title: 'Item 4',
44
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
45
+ }];
46
+ const contentAccordionItemsWithBodyAndHeaderAndFooter = [{
47
+ key: '1',
48
+ title: 'Item 1',
49
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
50
+ header: 'Header 1',
51
+ footer: /*#__PURE__*/_react2.default.createElement("span", null)
52
+ }, {
53
+ key: '2',
54
+ title: 'Item 2',
55
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
56
+ header: 'Header 2',
57
+ footer: /*#__PURE__*/_react2.default.createElement("span", null)
58
+ }, {
59
+ key: '3',
60
+ title: 'Item 3',
61
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
62
+ header: 'Header 3',
63
+ footer: /*#__PURE__*/_react2.default.createElement("span", null),
64
+ disabled: true
65
+ }, {
66
+ key: '4',
67
+ title: 'Item 4',
68
+ body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
69
+ header: 'Header 4',
70
+ footer: /*#__PURE__*/_react2.default.createElement("span", null)
71
+ }];
72
+ it('should render items in correct state', () => {
73
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
74
+ items: contentAccordionItemsWithBody
75
+ }));
76
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item').length).toBe(4);
77
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item disabled').length).toBe(1);
78
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item disabled')[0].id).toBe('item_3');
79
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(1);
80
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_2');
81
+ });
82
+ it('should not render header if not provided', () => {
83
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
84
+ items: contentAccordionItemsWithBody
85
+ }));
86
+ expect(wrapper.baseElement.getElementsByClassName('item-content-body').length).toBe(4);
87
+ expect(wrapper.baseElement.getElementsByClassName('item-content-header').length).toBe(0);
88
+ });
89
+ it('should not render footer if not provided', () => {
90
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
91
+ items: contentAccordionItemsWithBody
92
+ }));
93
+ expect(wrapper.baseElement.getElementsByClassName('item-content-body').length).toBe(4);
94
+ expect(wrapper.baseElement.getElementsByClassName('item-content-footer').length).toBe(0);
95
+ });
96
+ it('should render body, header, and footer if all are provided', () => {
97
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
98
+ items: contentAccordionItemsWithBodyAndHeaderAndFooter
99
+ }));
100
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item').length).toBe(4);
101
+ expect(wrapper.baseElement.getElementsByClassName('item-content-body').length).toBe(4);
102
+ expect(wrapper.baseElement.getElementsByClassName('item-content-header').length).toBe(4);
103
+ expect(wrapper.baseElement.getElementsByClassName('item-content-footer').length).toBe(4);
104
+ });
105
+ it('should set correct size class name for small accordion', () => {
106
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
107
+ items: contentAccordionItemsWithBodyAndHeaderAndFooter,
108
+ size: _types.Size.Small
109
+ }));
110
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion small').length).toBe(1);
111
+ });
112
+ it('should set correct size class name for medium accordion', () => {
113
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
114
+ items: contentAccordionItemsWithBodyAndHeaderAndFooter,
115
+ size: _types.Size.Medium
116
+ }));
117
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion medium').length).toBe(1);
118
+ });
119
+ it('should set correct size class name for large accordion', () => {
120
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
121
+ items: contentAccordionItemsWithBodyAndHeaderAndFooter,
122
+ size: _types.Size.Large
123
+ }));
124
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion large').length).toBe(1);
125
+ });
126
+ it('should change active state when item header is clicked', () => {
127
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
128
+ items: contentAccordionItemsWithBody,
129
+ multi: false
130
+ }));
131
+ const itemHeader = wrapper.baseElement.getElementsByClassName('item-header')[3];
132
+
133
+ _react3.fireEvent.click(itemHeader);
134
+
135
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(1);
136
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_4');
137
+ });
138
+ it('should not change active state when disabled item header is clicked', () => {
139
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
140
+ items: contentAccordionItemsWithBody,
141
+ multi: false
142
+ }));
143
+ const itemHeader = wrapper.baseElement.getElementsByClassName('item-header')[2];
144
+
145
+ _react3.fireEvent.click(itemHeader);
146
+
147
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(1);
148
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_2');
149
+ });
150
+ it('should append active items if multi property is true', () => {
151
+ const wrapper = (0, _react3.render)( /*#__PURE__*/_react2.default.createElement(_ContentAccordion2.default, {
152
+ items: contentAccordionItemsWithBody,
153
+ multi: true
154
+ }));
155
+ const itemHeader = wrapper.baseElement.getElementsByClassName('item-header')[3];
156
+
157
+ _react3.fireEvent.click(itemHeader);
158
+
159
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(2);
160
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_2');
161
+ expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[1].id).toBe('item_4');
162
+ });
163
+ });
164
+ });
165
+ //# sourceMappingURL=ContetnAccordion.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/Accordion/__tests__/ContetnAccordion.test.tsx"],"names":["describe","contentAccordionItemsWithBody","key","title","body","active","disabled","contentAccordionItemsWithBodyAndHeaderAndFooter","header","footer","it","wrapper","render","expect","Size","Small","Medium","Large","it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AAM,CAANA,CAAAA,IAAAA,CAAAA,CAAAA;AACAA,MAAAA,MAAM,CAACF,OAAO,CAAPA,WAAAA,CAAAA,sBAAAA,CAAAA,+BAAAA,EAAAA,CAAAA,EAAPE,EAAM,CAANA,CAAAA,IAAAA,CAAAA,QAAAA;AAPFH,KAAE,CAAFA;AAUAA,IAAAA,EAAE,CAAA,sDAAA,EAAyD,MAAM;AAC/D,YAAMC,OAAO,GAAGC,qBAAM,aAAC,gBAAA,aAAA,CAAA,0BAAA,EAAA;AAAkB,QAAA,KAAK,EAAvB,6BAAA;AAAwD,QAAA,KAAK,EAAE;AAA/D,OAAA,CAAPA,CAAhB;AACA,YAAMM,UAAU,GAAGP,OAAO,CAAPA,WAAAA,CAAAA,sBAAAA,CAAAA,aAAAA,EAAnB,CAAmBA,CAAnB;;AAEAQ,wBAAAA,KAAAA,CAAAA,UAAAA;;AAEAN,MAAAA,MAAM,CAACF,OAAO,CAAPA,WAAAA,CAAAA,sBAAAA,CAAAA,+BAAAA,EAAPE,MAAM,CAANA,CAAAA,IAAAA,CAAAA,CAAAA;AACAA,MAAAA,MAAM,CAACF,OAAO,CAAPA,WAAAA,CAAAA,sBAAAA,CAAAA,+BAAAA,EAAAA,CAAAA,EAAPE,EAAM,CAANA,CAAAA,IAAAA,CAAAA,QAAAA;AACAA,MAAAA,MAAM,CAACF,OAAO,CAAPA,WAAAA,CAAAA,sBAAAA,CAAAA,+BAAAA,EAAAA,CAAAA,EAAPE,EAAM,CAANA,CAAAA,IAAAA,CAAAA,QAAAA;AARFH,KAAE,CAAFA;AAjIFV,GAAQ,CAARA","sourcesContent":["import React from 'react';\nimport ContentAccordion from '../ContentAccordion';\nimport {fireEvent, render} from '@testing-library/react';\nimport {Size} from '../../types';\n\ndescribe('ContentAccordion', () => {\n const contentAccordionItemsWithBody = [\n {\n key: '1',\n title: 'Item 1',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'\n },\n {\n key: '2',\n title: 'Item 2',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n active: true\n },\n {\n key: '3',\n title: 'Item 3',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n disabled: true\n },\n {\n key: '4',\n title: 'Item 4',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'\n }\n ];\n\n const contentAccordionItemsWithBodyAndHeaderAndFooter = [\n {\n key: '1',\n title: 'Item 1',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n header: 'Header 1',\n footer: <span/>,\n },\n {\n key: '2',\n title: 'Item 2',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n header: 'Header 2',\n footer: <span/>,\n },\n {\n key: '3',\n title: 'Item 3',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n header: 'Header 3',\n footer: <span/>,\n disabled: true\n },\n {\n key: '4',\n title: 'Item 4',\n body: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',\n header: 'Header 4',\n footer: <span/>,\n }\n ];\n\n it('should render items in correct state', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBody}/>);\n\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item').length).toBe(4);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item disabled').length).toBe(1);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item disabled')[0].id).toBe('item_3');\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(1);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_2');\n });\n\n it('should not render header if not provided', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBody}/>);\n\n expect(wrapper.baseElement.getElementsByClassName('item-content-body').length).toBe(4);\n expect(wrapper.baseElement.getElementsByClassName('item-content-header').length).toBe(0);\n });\n\n it('should not render footer if not provided', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBody}/>);\n\n expect(wrapper.baseElement.getElementsByClassName('item-content-body').length).toBe(4);\n expect(wrapper.baseElement.getElementsByClassName('item-content-footer').length).toBe(0);\n });\n\n it('should render body, header, and footer if all are provided', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBodyAndHeaderAndFooter}/>);\n\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item').length).toBe(4);\n expect(wrapper.baseElement.getElementsByClassName('item-content-body').length).toBe(4);\n expect(wrapper.baseElement.getElementsByClassName('item-content-header').length).toBe(4);\n expect(wrapper.baseElement.getElementsByClassName('item-content-footer').length).toBe(4);\n });\n\n it('should set correct size class name for small accordion', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBodyAndHeaderAndFooter}\n size={Size.Small}/>);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion small').length).toBe(1);\n });\n\n it('should set correct size class name for medium accordion', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBodyAndHeaderAndFooter}\n size={Size.Medium}/>);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion medium').length).toBe(1);\n });\n\n it('should set correct size class name for large accordion', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBodyAndHeaderAndFooter}\n size={Size.Large}/>);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion large').length).toBe(1);\n });\n\n it('should change active state when item header is clicked', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBody} multi={false}/>);\n const itemHeader = wrapper.baseElement.getElementsByClassName('item-header')[3];\n\n fireEvent.click(itemHeader);\n\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(1);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_4');\n });\n\n it('should not change active state when disabled item header is clicked', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBody} multi={false}/>);\n const itemHeader = wrapper.baseElement.getElementsByClassName('item-header')[2];\n\n fireEvent.click(itemHeader);\n\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(1);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_2');\n });\n\n it('should append active items if multi property is true', () => {\n const wrapper = render(<ContentAccordion items={contentAccordionItemsWithBody} multi={true}/>);\n const itemHeader = wrapper.baseElement.getElementsByClassName('item-header')[3];\n\n fireEvent.click(itemHeader);\n\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active').length).toBe(2);\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[0].id).toBe('item_2');\n expect(wrapper.baseElement.getElementsByClassName('content-accordion-item active')[1].id).toBe('item_4');\n });\n\n});\n"],"file":"ContetnAccordion.test.js"}
@@ -1,16 +1,16 @@
1
1
  (function (global, factory) {
2
2
  if (typeof define === "function" && define.amd) {
3
- define(["exports", "./AccordionMenu", "./styles"], factory);
3
+ define(["exports", "./AccordionMenu", "./ContentAccordion", "./styles"], factory);
4
4
  } else if (typeof exports !== "undefined") {
5
- factory(exports, require("./AccordionMenu"), require("./styles"));
5
+ factory(exports, require("./AccordionMenu"), require("./ContentAccordion"), require("./styles"));
6
6
  } else {
7
7
  var mod = {
8
8
  exports: {}
9
9
  };
10
- factory(mod.exports, global.AccordionMenu, global.styles);
10
+ factory(mod.exports, global.AccordionMenu, global.ContentAccordion, global.styles);
11
11
  global.undefined = mod.exports;
12
12
  }
13
- })(this, function (exports, _AccordionMenu, _styles) {
13
+ })(this, function (exports, _AccordionMenu, _ContentAccordion, _styles) {
14
14
  "use strict";
15
15
 
16
16
  Object.defineProperty(exports, "__esModule", {
@@ -28,6 +28,12 @@
28
28
  return _interopRequireDefault(_AccordionMenu).default;
29
29
  }
30
30
  });
31
+ Object.defineProperty(exports, "ContentAccordion", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _ContentAccordion.ContentAccordion;
35
+ }
36
+ });
31
37
  Object.defineProperty(exports, "AccordionMenuWrapper", {
32
38
  enumerable: true,
33
39
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/Accordion/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;oDAAA,O;;;;;;oDACA,O;;;;;;qBACA,oB","sourcesContent":["export { default as AccordionMenu } from './AccordionMenu';\nexport { default as AccordionMenuItem } from './AccordionMenu';\nexport { AccordionMenuWrapper } from './styles';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../../src/Accordion/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;oDAAA,O;;;;;;oDACA,O;;;;;;+BACA,gB;;;;;;qBACA,oB","sourcesContent":["export {default as AccordionMenu} from './AccordionMenu';\nexport {default as AccordionMenuItem} from './AccordionMenu';\nexport {ContentAccordion} from './ContentAccordion';\nexport {AccordionMenuWrapper} from './styles';\n"],"file":"index.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laerdal/life-react-components",
3
- "version": "1.3.1-dev.3.full",
3
+ "version": "1.3.1-dev.4",
4
4
  "private": false,
5
5
  "author": "Thomas Kalve <thomas.kalve@laerdal.com>",
6
6
  "contributors": [
@@ -1,154 +0,0 @@
1
- import React from 'react';
2
- import { render } from '@testing-library/react';
3
- import 'jest-styled-components';
4
- import { ModalDialog } from '..';
5
- import { Size, SystemIcons } from '../..';
6
- describe('<ModalDialog />', () => {
7
- let mountingDiv;
8
- beforeEach(() => {
9
- //being rendered as a React.Portal we need to have the 'root' div defined
10
- mountingDiv = document.createElement('div');
11
- mountingDiv.id = 'root';
12
- document.body.appendChild(mountingDiv);
13
- });
14
- afterEach(() => {
15
- document.body.removeChild(mountingDiv);
16
- });
17
- it('Check modal not rendered when isModalOpen is false', async () => {
18
- const {
19
- container,
20
- getByText
21
- } = render( /*#__PURE__*/React.createElement(ModalDialog, {
22
- key: "smallModalWithoutImage",
23
- closeModalAndClearInput: () => {},
24
- title: 'Header',
25
- size: Size.Small,
26
- isModalOpen: false,
27
- closeAction: () => {},
28
- submitAction: () => {}
29
- })); //check modal portal not exists when modal not opened
30
-
31
- expect(container.querySelector('.ReactModalPortal')).toBeNull();
32
- });
33
- it('Check modal visible, title and footer buttons displayed correctly', async () => {
34
- const {
35
- container,
36
- getByText
37
- } = render( /*#__PURE__*/React.createElement(ModalDialog, {
38
- key: "smallModalWithoutImage",
39
- closeModalAndClearInput: () => {},
40
- title: 'Header',
41
- size: Size.Small,
42
- isModalOpen: true,
43
- closeAction: () => {},
44
- submitAction: () => {},
45
- buttons: [{
46
- action: () => {},
47
- text: 'Close',
48
- variant: 'tertiary'
49
- }, {
50
- action: () => {},
51
- text: 'Save'
52
- }]
53
- })); //check modal portal defined
54
-
55
- expect(container.querySelector('.ReactModalPortal')).toBeDefined(); //Check header and footer buttons
56
-
57
- expect(getByText('Header')).toBeDefined();
58
- expect(getByText('Close')).toBeDefined();
59
- expect(getByText('Save')).toBeDefined();
60
- });
61
- it('Check tooltip, and link displayed without right footer buttons', async () => {
62
- const {
63
- baseElement,
64
- getByText
65
- } = render( /*#__PURE__*/React.createElement(ModalDialog, {
66
- key: "smallModalWithoutImage",
67
- closeModalAndClearInput: () => {},
68
- title: 'Header',
69
- size: Size.Small,
70
- isModalOpen: true,
71
- closeAction: () => {},
72
- submitAction: () => {},
73
- tooltip: 'some test tooltip',
74
- leftFooterAction: {
75
- id: 'test-link',
76
- actionType: 'hyperlink',
77
- text: 'Link',
78
- href: 'http://test.com',
79
- icon: /*#__PURE__*/React.createElement(React.Fragment, null),
80
- variant: 'default'
81
- }
82
- })); //check tooltip displayed
83
-
84
- expect(getByText('some test tooltip').textContent).toBeDefined(); //check footer link displayed
85
-
86
- expect(getByText('Link').children).toBeDefined();
87
- });
88
- it('Check note and footer note displayed', async () => {
89
- const {
90
- baseElement,
91
- getByText
92
- } = render( /*#__PURE__*/React.createElement(ModalDialog, {
93
- key: "smallModalWithoutImage",
94
- closeModalAndClearInput: () => {},
95
- title: 'Header',
96
- size: Size.Small,
97
- isModalOpen: true,
98
- closeAction: () => {},
99
- submitAction: () => {},
100
- leftFooterAction: {
101
- id: 'test-note',
102
- actionType: 'note',
103
- text: 'Test note',
104
- icon: /*#__PURE__*/React.createElement(SystemIcons.Information, null)
105
- },
106
- note: 'Message text',
107
- state: 'critical'
108
- })); //check footer note text displayed
109
-
110
- expect(getByText('Test note').textContent).toBeDefined(); //check note section added
111
-
112
- expect(baseElement.querySelectorAll('section')?.length).toEqual(4); //check note message displayed
113
-
114
- expect(getByText('Message text').children).toBeDefined();
115
- });
116
- it('Check back button and close icon displayed', async () => {
117
- const {
118
- baseElement,
119
- getByText,
120
- container
121
- } = render( /*#__PURE__*/React.createElement(ModalDialog, {
122
- key: "smallModalWithoutImage",
123
- closeModalAndClearInput: () => {},
124
- title: 'Header',
125
- size: Size.Small,
126
- backButton: () => {},
127
- isModalOpen: true,
128
- closeAction: () => {},
129
- submitAction: () => {}
130
- })); //only 2 svg elements should be found in the header of the modal
131
-
132
- expect(baseElement.querySelectorAll('svg')?.length).toEqual(2);
133
- });
134
- it('Check modal body displayed', async () => {
135
- const {
136
- baseElement,
137
- getByText,
138
- container
139
- } = render( /*#__PURE__*/React.createElement(ModalDialog, {
140
- key: "smallModalWithoutImage",
141
- closeModalAndClearInput: () => {},
142
- title: 'Header',
143
- size: Size.Small,
144
- isModalOpen: true,
145
- closeAction: () => {},
146
- submitAction: () => {}
147
- }, /*#__PURE__*/React.createElement("span", null, "Inner modal text"))); //Check all dialog sections are displayed
148
-
149
- expect(baseElement.querySelectorAll('section')?.length).toEqual(3); //Check that the second section (modal body) has the correct text
150
-
151
- expect(baseElement.querySelectorAll('section')?.[1].textContent).toEqual('Inner modal text');
152
- });
153
- });
154
- //# sourceMappingURL=Modal.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/Modals/__tests__/Modal.test.tsx"],"names":["React","render","ModalDialog","Size","SystemIcons","describe","mountingDiv","beforeEach","document","createElement","id","body","appendChild","afterEach","removeChild","it","container","getByText","Small","expect","querySelector","toBeNull","action","text","variant","toBeDefined","baseElement","actionType","href","icon","textContent","children","querySelectorAll","length","toEqual"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,MAAT,QAAuB,wBAAvB;AACA,OAAO,wBAAP;AACA,SAASC,WAAT,QAA4B,IAA5B;AACA,SAAiBC,IAAjB,EAAuBC,WAAvB,QAA0C,OAA1C;AAEAC,QAAQ,CAAC,iBAAD,EAAoB,MAAM;AAChC,MAAIC,WAAJ;AAEAC,EAAAA,UAAU,CAAC,MAAM;AACf;AACAD,IAAAA,WAAW,GAAGE,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAd;AACAH,IAAAA,WAAW,CAACI,EAAZ,GAAiB,MAAjB;AACAF,IAAAA,QAAQ,CAACG,IAAT,CAAcC,WAAd,CAA0BN,WAA1B;AACD,GALS,CAAV;AAOAO,EAAAA,SAAS,CAAC,MAAM;AACdL,IAAAA,QAAQ,CAACG,IAAT,CAAcG,WAAd,CAA0BR,WAA1B;AACD,GAFQ,CAAT;AAIAS,EAAAA,EAAE,CAAC,oDAAD,EAAuD,YAAY;AACnE,UAAM;AAAEC,MAAAA,SAAF;AAAaC,MAAAA;AAAb,QAA2BhB,MAAM,eACrC,oBAAC,WAAD;AACE,MAAA,GAAG,EAAC,wBADN;AAEE,MAAA,uBAAuB,EAAE,MAAM,CAAE,CAFnC;AAGE,MAAA,KAAK,EAAE,QAHT;AAIE,MAAA,IAAI,EAAEE,IAAI,CAACe,KAJb;AAKE,MAAA,WAAW,EAAE,KALf;AAME,MAAA,WAAW,EAAE,MAAM,CAAE,CANvB;AAOE,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,GAfC,CAAF;AAiBAnB,EAAAA,EAAE,CAAC,4BAAD,EAA+B,YAAY;AAC3C,UAAM;AAAEW,MAAAA,WAAF;AAAeT,MAAAA,SAAf;AAA0BD,MAAAA;AAA1B,QAAwCf,MAAM,eAClD,oBAAC,WAAD;AACE,MAAA,GAAG,EAAC,wBADN;AAEE,MAAA,uBAAuB,EAAE,MAAM,CAAE,CAFnC;AAGE,MAAA,KAAK,EAAE,QAHT;AAIE,MAAA,IAAI,EAAEE,IAAI,CAACe,KAJb;AAKE,MAAA,WAAW,EAAE,IALf;AAME,MAAA,WAAW,EAAE,MAAM,CAAE,CANvB;AAOE,MAAA,YAAY,EAAE,MAAM,CAAE;AAPxB,oBAQE,qDARF,CADkD,CAApD,CAD2C,CAa3C;;AACAC,IAAAA,MAAM,CAACO,WAAW,CAACM,gBAAZ,CAA6B,SAA7B,GAAyCC,MAA1C,CAAN,CAAwDC,OAAxD,CAAgE,CAAhE,EAd2C,CAe3C;;AACAf,IAAAA,MAAM,CAACO,WAAW,CAACM,gBAAZ,CAA6B,SAA7B,IAA0C,CAA1C,EAA6CF,WAA9C,CAAN,CAAiEI,OAAjE,CAAyE,kBAAzE;AACD,GAjBC,CAAF;AAkBD,CA3IO,CAAR","sourcesContent":["import React from 'react';\nimport { render } from '@testing-library/react';\nimport 'jest-styled-components';\nimport { ModalDialog } from '..';\nimport { COLORS, Size, SystemIcons } from '../..';\n\ndescribe('<ModalDialog />', () => {\n let mountingDiv: HTMLElement;\n\n beforeEach(() => {\n //being rendered as a React.Portal we need to have the 'root' div defined\n mountingDiv = document.createElement('div');\n mountingDiv.id = 'root';\n document.body.appendChild(mountingDiv);\n });\n\n afterEach(() => {\n document.body.removeChild(mountingDiv);\n });\n\n it('Check modal not rendered when isModalOpen is false', async () => {\n const { container, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={false}\n closeAction={() => {}}\n submitAction={() => {}}\n />,\n );\n //check modal portal not exists when modal not opened\n expect(container.querySelector('.ReactModalPortal')).toBeNull();\n });\n\n it('Check modal visible, title and footer buttons displayed correctly', async () => {\n const { container, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n buttons={[\n {\n action: () => {},\n text: 'Close',\n variant: 'tertiary',\n },\n {\n action: () => {},\n text: 'Save',\n },\n ]}\n />,\n );\n //check modal portal defined\n expect(container.querySelector('.ReactModalPortal')).toBeDefined();\n //Check header and footer buttons\n expect(getByText('Header')).toBeDefined();\n expect(getByText('Close')).toBeDefined();\n expect(getByText('Save')).toBeDefined();\n });\n\n it('Check tooltip, and link displayed without right footer buttons', async () => {\n const { baseElement, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n tooltip={'some test tooltip'}\n leftFooterAction={{ id: 'test-link', actionType: 'hyperlink', text: 'Link', href: 'http://test.com', icon: <></>, variant: 'default' }}\n />,\n );\n //check tooltip displayed\n expect(getByText('some test tooltip').textContent).toBeDefined();\n //check footer link displayed\n expect(getByText('Link').children).toBeDefined();\n });\n\n it('Check note and footer note displayed', async () => {\n const { baseElement, getByText } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n leftFooterAction={{ id: 'test-note', actionType: 'note', text: 'Test note', icon: <SystemIcons.Information /> }}\n note={'Message text'}\n state={'critical'}\n />,\n );\n //check footer note text displayed\n expect(getByText('Test note').textContent).toBeDefined();\n //check note section added\n expect(baseElement.querySelectorAll('section')?.length).toEqual(4);\n //check note message displayed\n expect(getByText('Message text').children).toBeDefined();\n });\n\n it('Check back button and close icon displayed', async () => {\n const { baseElement, getByText, container } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n backButton={() => {}}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}\n />,\n );\n //only 2 svg elements should be found in the header of the modal\n expect(baseElement.querySelectorAll('svg')?.length).toEqual(2);\n });\n\n it('Check modal body displayed', async () => {\n const { baseElement, getByText, container } = render(\n <ModalDialog\n key=\"smallModalWithoutImage\"\n closeModalAndClearInput={() => {}}\n title={'Header'}\n size={Size.Small}\n isModalOpen={true}\n closeAction={() => {}}\n submitAction={() => {}}>\n <span>Inner modal text</span>\n </ModalDialog>,\n );\n //Check all dialog sections are displayed\n expect(baseElement.querySelectorAll('section')?.length).toEqual(3);\n //Check that the second section (modal body) has the correct text\n expect(baseElement.querySelectorAll('section')?.[1].textContent).toEqual('Inner modal text');\n });\n});\n"],"file":"Modal.test.js"}
@@ -1,231 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _react2 = require("@testing-library/react");
6
-
7
- require("jest-styled-components");
8
-
9
- var _ = require("..");
10
-
11
- var _2 = require("../..");
12
-
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
16
-
17
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
-
19
- describe('<ModalDialog />', function () {
20
- var mountingDiv;
21
- beforeEach(function () {
22
- //being rendered as a React.Portal we need to have the 'root' div defined
23
- mountingDiv = document.createElement('div');
24
- mountingDiv.id = 'root';
25
- document.body.appendChild(mountingDiv);
26
- });
27
- afterEach(function () {
28
- document.body.removeChild(mountingDiv);
29
- });
30
- it('Check modal not rendered when isModalOpen is false', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
31
- var _render, container, getByText;
32
-
33
- return regeneratorRuntime.wrap(function _callee$(_context) {
34
- while (1) {
35
- switch (_context.prev = _context.next) {
36
- case 0:
37
- _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
38
- key: "smallModalWithoutImage",
39
- closeModalAndClearInput: function closeModalAndClearInput() {},
40
- title: 'Header',
41
- size: _2.Size.Small,
42
- isModalOpen: false,
43
- closeAction: function closeAction() {},
44
- submitAction: function submitAction() {}
45
- })), container = _render.container, getByText = _render.getByText; //check modal portal not exists when modal not opened
46
-
47
- expect(container.querySelector('.ReactModalPortal')).toBeNull();
48
-
49
- case 2:
50
- case "end":
51
- return _context.stop();
52
- }
53
- }
54
- }, _callee);
55
- })));
56
- it('Check modal visible, title and footer buttons displayed correctly', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
57
- var _render2, container, getByText;
58
-
59
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
60
- while (1) {
61
- switch (_context2.prev = _context2.next) {
62
- case 0:
63
- _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
64
- key: "smallModalWithoutImage",
65
- closeModalAndClearInput: function closeModalAndClearInput() {},
66
- title: 'Header',
67
- size: _2.Size.Small,
68
- isModalOpen: true,
69
- closeAction: function closeAction() {},
70
- submitAction: function submitAction() {},
71
- buttons: [{
72
- action: function action() {},
73
- text: 'Close',
74
- variant: 'tertiary'
75
- }, {
76
- action: function action() {},
77
- text: 'Save'
78
- }]
79
- })), container = _render2.container, getByText = _render2.getByText; //check modal portal defined
80
-
81
- expect(container.querySelector('.ReactModalPortal')).toBeDefined(); //Check header and footer buttons
82
-
83
- expect(getByText('Header')).toBeDefined();
84
- expect(getByText('Close')).toBeDefined();
85
- expect(getByText('Save')).toBeDefined();
86
-
87
- case 5:
88
- case "end":
89
- return _context2.stop();
90
- }
91
- }
92
- }, _callee2);
93
- })));
94
- it('Check tooltip, and link displayed without right footer buttons', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
95
- var _render3, baseElement, getByText;
96
-
97
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
98
- while (1) {
99
- switch (_context3.prev = _context3.next) {
100
- case 0:
101
- _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
102
- key: "smallModalWithoutImage",
103
- closeModalAndClearInput: function closeModalAndClearInput() {},
104
- title: 'Header',
105
- size: _2.Size.Small,
106
- isModalOpen: true,
107
- closeAction: function closeAction() {},
108
- submitAction: function submitAction() {},
109
- tooltip: 'some test tooltip',
110
- leftFooterAction: {
111
- id: 'test-link',
112
- actionType: 'hyperlink',
113
- text: 'Link',
114
- href: 'http://test.com',
115
- icon: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null),
116
- variant: 'default'
117
- }
118
- })), baseElement = _render3.baseElement, getByText = _render3.getByText; //check tooltip displayed
119
-
120
- expect(getByText('some test tooltip').textContent).toBeDefined(); //check footer link displayed
121
-
122
- expect(getByText('Link').children).toBeDefined();
123
-
124
- case 3:
125
- case "end":
126
- return _context3.stop();
127
- }
128
- }
129
- }, _callee3);
130
- })));
131
- it('Check note and footer note displayed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
132
- var _baseElement$querySel;
133
-
134
- var _render4, baseElement, getByText;
135
-
136
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
137
- while (1) {
138
- switch (_context4.prev = _context4.next) {
139
- case 0:
140
- _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
141
- key: "smallModalWithoutImage",
142
- closeModalAndClearInput: function closeModalAndClearInput() {},
143
- title: 'Header',
144
- size: _2.Size.Small,
145
- isModalOpen: true,
146
- closeAction: function closeAction() {},
147
- submitAction: function submitAction() {},
148
- leftFooterAction: {
149
- id: 'test-note',
150
- actionType: 'note',
151
- text: 'Test note',
152
- icon: /*#__PURE__*/_react.default.createElement(_2.SystemIcons.Information, null)
153
- },
154
- note: 'Message text',
155
- state: 'critical'
156
- })), baseElement = _render4.baseElement, getByText = _render4.getByText; //check footer note text displayed
157
-
158
- expect(getByText('Test note').textContent).toBeDefined(); //check note section added
159
-
160
- expect((_baseElement$querySel = baseElement.querySelectorAll('section')) === null || _baseElement$querySel === void 0 ? void 0 : _baseElement$querySel.length).toEqual(4); //check note message displayed
161
-
162
- expect(getByText('Message text').children).toBeDefined();
163
-
164
- case 4:
165
- case "end":
166
- return _context4.stop();
167
- }
168
- }
169
- }, _callee4);
170
- })));
171
- it('Check back button and close icon displayed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
172
- var _baseElement$querySel2;
173
-
174
- var _render5, baseElement, getByText, container;
175
-
176
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
177
- while (1) {
178
- switch (_context5.prev = _context5.next) {
179
- case 0:
180
- _render5 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
181
- key: "smallModalWithoutImage",
182
- closeModalAndClearInput: function closeModalAndClearInput() {},
183
- title: 'Header',
184
- size: _2.Size.Small,
185
- backButton: function backButton() {},
186
- isModalOpen: true,
187
- closeAction: function closeAction() {},
188
- submitAction: function submitAction() {}
189
- })), baseElement = _render5.baseElement, getByText = _render5.getByText, container = _render5.container; //only 2 svg elements should be found in the header of the modal
190
-
191
- expect((_baseElement$querySel2 = baseElement.querySelectorAll('svg')) === null || _baseElement$querySel2 === void 0 ? void 0 : _baseElement$querySel2.length).toEqual(2);
192
-
193
- case 2:
194
- case "end":
195
- return _context5.stop();
196
- }
197
- }
198
- }, _callee5);
199
- })));
200
- it('Check modal body displayed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6() {
201
- var _baseElement$querySel3, _baseElement$querySel4;
202
-
203
- var _render6, baseElement, getByText, container;
204
-
205
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
206
- while (1) {
207
- switch (_context6.prev = _context6.next) {
208
- case 0:
209
- _render6 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_.ModalDialog, {
210
- key: "smallModalWithoutImage",
211
- closeModalAndClearInput: function closeModalAndClearInput() {},
212
- title: 'Header',
213
- size: _2.Size.Small,
214
- isModalOpen: true,
215
- closeAction: function closeAction() {},
216
- submitAction: function submitAction() {}
217
- }, /*#__PURE__*/_react.default.createElement("span", null, "Inner modal text"))), baseElement = _render6.baseElement, getByText = _render6.getByText, container = _render6.container; //Check all dialog sections are displayed
218
-
219
- expect((_baseElement$querySel3 = baseElement.querySelectorAll('section')) === null || _baseElement$querySel3 === void 0 ? void 0 : _baseElement$querySel3.length).toEqual(3); //Check that the second section (modal body) has the correct text
220
-
221
- expect((_baseElement$querySel4 = baseElement.querySelectorAll('section')) === null || _baseElement$querySel4 === void 0 ? void 0 : _baseElement$querySel4[1].textContent).toEqual('Inner modal text');
222
-
223
- case 3:
224
- case "end":
225
- return _context6.stop();
226
- }
227
- }
228
- }, _callee6);
229
- })));
230
- });
231
- //# sourceMappingURL=Modal.test.js.map