@laerdal/life-react-components 6.0.0-dev.20.full → 6.0.0-dev.5.full

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 (112) hide show
  1. package/dist/Button/Button.cjs +5 -0
  2. package/dist/Button/Button.cjs.map +1 -1
  3. package/dist/Button/Button.js +5 -0
  4. package/dist/Button/Button.js.map +1 -1
  5. package/dist/GlobalNavigationBar/Logo.cjs +1 -2
  6. package/dist/GlobalNavigationBar/Logo.cjs.map +1 -1
  7. package/dist/GlobalNavigationBar/Logo.js +1 -2
  8. package/dist/GlobalNavigationBar/Logo.js.map +1 -1
  9. package/dist/GlobalNavigationBar/desktop/MainMenu.cjs +1 -10
  10. package/dist/GlobalNavigationBar/desktop/MainMenu.cjs.map +1 -1
  11. package/dist/GlobalNavigationBar/desktop/MainMenu.js +1 -10
  12. package/dist/GlobalNavigationBar/desktop/MainMenu.js.map +1 -1
  13. package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs +2 -3
  14. package/dist/GlobalNavigationBar/desktop/RightSideNav.cjs.map +1 -1
  15. package/dist/GlobalNavigationBar/desktop/RightSideNav.js +2 -3
  16. package/dist/GlobalNavigationBar/desktop/RightSideNav.js.map +1 -1
  17. package/dist/GlobalNavigationBar/mobile/CommonStyles.cjs.map +1 -1
  18. package/dist/GlobalNavigationBar/mobile/CommonStyles.js.map +1 -1
  19. package/dist/HyperLink/HyperLink.cjs +2 -18
  20. package/dist/HyperLink/HyperLink.cjs.map +1 -1
  21. package/dist/HyperLink/HyperLink.d.ts +0 -2
  22. package/dist/HyperLink/HyperLink.js +2 -18
  23. package/dist/HyperLink/HyperLink.js.map +1 -1
  24. package/dist/InputFields/DatepickerField.cjs +1 -1
  25. package/dist/InputFields/DatepickerField.cjs.map +1 -1
  26. package/dist/InputFields/DatepickerField.d.ts +1 -1
  27. package/dist/InputFields/DatepickerField.js +1 -1
  28. package/dist/InputFields/DatepickerField.js.map +1 -1
  29. package/dist/InputFields/TextField.cjs +1 -1
  30. package/dist/InputFields/TextField.cjs.map +1 -1
  31. package/dist/InputFields/TextField.js +1 -1
  32. package/dist/InputFields/TextField.js.map +1 -1
  33. package/dist/MiniProductCard/MiniProductCard.cjs +1 -15
  34. package/dist/MiniProductCard/MiniProductCard.cjs.map +1 -1
  35. package/dist/MiniProductCard/MiniProductCard.d.ts +0 -1
  36. package/dist/MiniProductCard/MiniProductCard.js +1 -15
  37. package/dist/MiniProductCard/MiniProductCard.js.map +1 -1
  38. package/dist/NavItem/NavItem.cjs +1 -7
  39. package/dist/NavItem/NavItem.cjs.map +1 -1
  40. package/dist/NavItem/NavItem.js +1 -7
  41. package/dist/NavItem/NavItem.js.map +1 -1
  42. package/dist/Tabs/VerticalTabs.cjs +0 -1
  43. package/dist/Tabs/VerticalTabs.cjs.map +1 -1
  44. package/dist/Tabs/VerticalTabs.js +0 -1
  45. package/dist/Tabs/VerticalTabs.js.map +1 -1
  46. package/dist/styles/colors.cjs +1 -0
  47. package/dist/styles/colors.cjs.map +1 -1
  48. package/dist/styles/colors.js +1 -0
  49. package/dist/styles/colors.js.map +1 -1
  50. package/dist/styles/index.cjs +5 -5
  51. package/dist/styles/index.cjs.map +1 -1
  52. package/dist/styles/index.d.ts +2 -2
  53. package/dist/styles/index.js +2 -2
  54. package/dist/styles/index.js.map +1 -1
  55. package/package.json +4 -5
  56. package/dist/Accordion/__tests__/AccordionMenu.test.tsx +0 -42
  57. package/dist/Accordion/__tests__/ContentAccordion.test.tsx +0 -150
  58. package/dist/AuthPage/__tests__/AuthPage.test.tsx +0 -27
  59. package/dist/Banners/__tests__/Banner.test.tsx +0 -47
  60. package/dist/Banners/__tests__/OverviewBanner.test.tsx +0 -20
  61. package/dist/Breadcrumb/__tests__/Breadcrumb.test.tsx +0 -78
  62. package/dist/Button/__tests__/BackButton.test.tsx +0 -32
  63. package/dist/Button/__tests__/Button.test.tsx +0 -45
  64. package/dist/Button/__tests__/DualButton.test.tsx +0 -119
  65. package/dist/Card/HorizontalCard/__tests__/HorizontalCard.test.tsx +0 -71
  66. package/dist/Card/HorizontalCard/__tests__/VerticalCard.test.tsx +0 -124
  67. package/dist/Card/__tests__/Card.test.tsx +0 -146
  68. package/dist/Chips/__tests__/ActionChip.test.tsx +0 -94
  69. package/dist/Chips/__tests__/ChoiceChips.test.tsx +0 -79
  70. package/dist/Chips/__tests__/FilterChip.test.tsx +0 -95
  71. package/dist/Chips/__tests__/InputChip.test.tsx +0 -155
  72. package/dist/ChipsInput/__tests__/ChipDropdownInput.test.tsx +0 -100
  73. package/dist/ChipsInput/__tests__/ChipInputFields.test.tsx +0 -155
  74. package/dist/Dropdown/__tests__/DropdownFilter.test.tsx +0 -39
  75. package/dist/Footer/__tests__/Footer.test.tsx +0 -182
  76. package/dist/GlobalNavigationBar/__tests__/Logo.test.tsx +0 -39
  77. package/dist/GlobalNavigationBar/desktop/__tests__/DesktopActions.test.tsx +0 -108
  78. package/dist/GlobalNavigationBar/desktop/__tests__/ExtendedMainMenu.test.tsx +0 -28
  79. package/dist/GlobalNavigationBar/desktop/__tests__/MainMenu.test.tsx +0 -55
  80. package/dist/GlobalNavigationBar/desktop/__tests__/RightSideNav.test.tsx +0 -45
  81. package/dist/GlobalNavigationBar/desktop/__tests__/UserMenu.test.tsx +0 -125
  82. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenu.test.tsx +0 -317
  83. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuContent.test.tsx +0 -294
  84. package/dist/GlobalNavigationBar/mobile/__tests__/MobileMenuHeader.test.tsx +0 -195
  85. package/dist/InputFields/__tests__/NumberField.test.tsx +0 -67
  86. package/dist/InputFields/__tests__/NumberInput.test.tsx +0 -68
  87. package/dist/InputFields/__tests__/QuickSearch.test.tsx +0 -42
  88. package/dist/LinearProgress/__tests__/LinearProgress.test.tsx +0 -25
  89. package/dist/List/__tests__/ListRow.test.tsx +0 -18
  90. package/dist/LoadingPage/__tests__/GlobalLoadingPage.test.tsx +0 -23
  91. package/dist/Modals/__tests__/Modal.test.tsx +0 -169
  92. package/dist/Modals/__tests__/ModalContainer.test.tsx +0 -77
  93. package/dist/Modals/__tests__/ModalContent.test.tsx +0 -126
  94. package/dist/NavItem/__tests__/NavItem.test.ts +0 -6
  95. package/dist/NotificationDot/__tests__/NotificationDot.test.tsx +0 -33
  96. package/dist/Paginator/__tests__/Paginator.test.tsx +0 -39
  97. package/dist/Popover/__tests__/Popover.test.tsx +0 -64
  98. package/dist/ProfileButton/__tests__/ProfileButton.test.tsx +0 -31
  99. package/dist/QuizButton/__tests__/QuizButton.test.tsx +0 -53
  100. package/dist/SegmentControl/__tests__/SegmentControl.test.tsx +0 -145
  101. package/dist/SideMenu/__tests__/SideMenu.test.tsx +0 -99
  102. package/dist/Switcher/__tests__/SwitcherMenuItem.tsx +0 -14
  103. package/dist/Table/__tests__/Table.test.tsx +0 -499
  104. package/dist/Tabs/__tests__/HorizontalTabs.test.tsx +0 -95
  105. package/dist/Tabs/__tests__/TabLink.test.tsx +0 -40
  106. package/dist/Tabs/__tests__/Tablist.test.tsx +0 -37
  107. package/dist/Tag/__tests__/Tag.test.tsx +0 -86
  108. package/dist/Toasters/__tests__/Toast.test.tsx +0 -74
  109. package/dist/Toggles/__tests__/ToggleButton.test.tsx +0 -53
  110. package/dist/Toggles/__tests__/ToggleSwitch.test.tsx +0 -87
  111. package/dist/Tooltips/__tests__/TooltipWrapper.test.tsx +0 -16
  112. package/dist/styles/react-datepicker.css +0 -766
@@ -1,47 +0,0 @@
1
- import React from 'react';
2
- import { render } from '../../test-utils';
3
- import { Banner } from '../index';
4
- import 'jest-styled-components';
5
- import { COLORS } from '../../styles';
6
-
7
-
8
-
9
-
10
- describe('<Banner />', () => {
11
- it('Renders warning banner', async () => {
12
- const { queryByText, getByTestId } = render(
13
- <Banner type="warning" testId="TestBanner">
14
- <h2>TestBanner</h2>
15
- </Banner>,
16
- );
17
- expect(queryByText('TestHeader')).toBeDefined();
18
- expect(getByTestId('TestBanner')).toHaveStyleRule('background', COLORS.bg_surface_warning);
19
- });
20
- it('Renders critial banner', async () => {
21
- const { queryByText, getByTestId } = render(
22
- <Banner type="critical" testId="TestBanner">
23
- <h2>TestBanner</h2>
24
- </Banner>,
25
- );
26
- expect(queryByText('TestHeader')).toBeDefined();
27
- expect(getByTestId('TestBanner')).toHaveStyleRule('background', COLORS.bg_surface_critical);
28
- });
29
- it('Renders positive banner', async () => {
30
- const { queryByText, getByTestId } = render(
31
- <Banner type="positive" testId="TestBanner">
32
- <h2>TestBanner</h2>
33
- </Banner>,
34
- );
35
- expect(queryByText('TestHeader')).toBeDefined();
36
- expect(getByTestId('TestBanner')).toHaveStyleRule('background', COLORS.bg_surface_positive);
37
- });
38
- it('Renders default banner', async () => {
39
- const { queryByText, getByTestId } = render(
40
- <Banner testId="TestBanner">
41
- <h2>TestBanner</h2>
42
- </Banner>,
43
- );
44
- expect(queryByText('TestHeader')).toBeDefined();
45
- expect(getByTestId('TestBanner')).toHaveStyleRule('background', COLORS.bg_surface_primary);
46
- });
47
- });
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { render } from '../../test-utils';
3
- import { OverviewBanner } from '../index';
4
- import 'jest-styled-components';
5
- import { COLORS } from '../../styles';
6
-
7
-
8
-
9
-
10
- describe('<OverviewBanner />', () => {
11
- it('Renders', async () => {
12
- const { queryByText, getByTestId } = render(
13
- <OverviewBanner testId="TestBanner">
14
- <h2>TestHeader</h2>
15
- </OverviewBanner>,
16
- );
17
- expect(queryByText('TestHeader')).toBeDefined();
18
- expect(getByTestId('TestBanner')).toHaveStyleRule('background-color', COLORS.primary_20);
19
- });
20
- });
@@ -1,78 +0,0 @@
1
- import React from 'react';
2
- import { render } from '../../test-utils';
3
- import { Breadcrumb } from '../index';
4
- import '@testing-library/jest-dom';
5
- import { Size } from '../../types';
6
-
7
- const items = [
8
- { label: 'test1', url: 'http://laerdal_test.com', callback: (id?: string) => {} },
9
- { label: 'test2', url: 'http://laerdal_test1.com', callback: (id?: string) => {} },
10
- { label: 'test3', url: 'http://laerdal_test2.com', callback: (id?: string) => {} },
11
- { label: 'test4', url: 'http://laerdal_test3.com', callback: (id?: string) => {} },
12
- ];
13
-
14
-
15
-
16
- describe('<Breadcrumb />', () => {
17
- it('Renders with no values', async () => {
18
- const { getByTestId, container } = render(<Breadcrumb items={[]} />);
19
- //main container is displayed
20
- expect(getByTestId('breacrumbContainer')).toBeDefined();
21
- //home link is displayed
22
- expect(container.querySelector('[id="homelink"]')).toBeDefined();
23
- });
24
-
25
- it('Renders with home icon and no values', async () => {
26
- const { getByTestId, container } = render(<Breadcrumb items={[]} homeIcon={true} />);
27
- expect(getByTestId('breacrumbContainer')).toBeDefined();
28
- //home icon is displayed
29
- expect(container.querySelector('[id="homeIcon"]')).toBeDefined();
30
-
31
- //because a size was not provided, small icons width will be set (20px)
32
- const svg = container.querySelector('svg');
33
- expect(svg).toHaveAttribute('width', '20px');
34
- });
35
-
36
- it('Render breadcrumb with two values ', async () => {
37
- const options = items.slice(0, 2);
38
- const { getByTestId, container } = render(<Breadcrumb lastItemAsLabel={true} items={options} size={Size.Medium} />);
39
- expect(getByTestId('breacrumbContainer')).toBeDefined();
40
- //check breadcrumbs displayed correctly - only one link defined for this scenario
41
- const linkItem = container.querySelector('a[id*="link-item"]');
42
- expect(linkItem).toBeDefined();
43
- expect(linkItem).toHaveTextContent(options[0].label);
44
-
45
- //query breadcrumb chrevron separators
46
- const breadcrumbSeparators = container.querySelectorAll('.chevronicon');
47
- expect(breadcrumbSeparators).toBeDefined();
48
- expect(breadcrumbSeparators).toHaveLength(2);
49
-
50
- //medium size provided
51
- const svg = container.querySelector('svg');
52
- expect(svg).toHaveAttribute('width', '24px');
53
-
54
- const lastItem = container.querySelector('label');
55
- expect(lastItem).toBeDefined();
56
- expect(lastItem).toHaveTextContent(options[options.length - 1].label);
57
- });
58
-
59
- it('Render more than 3 items', async () => {
60
- const { container, getByText } = render(<Breadcrumb lastItemAsLabel={true} items={items} size={Size.XSmall} />);
61
-
62
- //having more than 2 item show more dropdown selector should be displayed
63
- //because home page button is not provided, only one button should be rendered
64
- const showMoreBtn = container.querySelector('button');
65
- expect(showMoreBtn).toBeDefined();
66
- //in this scenario, first option label is not displayed, so only one link item available
67
- const linkItem = container.querySelectorAll('a[id*="link-item"]');
68
- expect(linkItem).toHaveLength(1);
69
-
70
- //links not displayed for first two items, but these are defined as dropdown options
71
- expect(getByText(items[0].label)).toBeDefined();
72
- expect(getByText(items[1].label)).toBeDefined();
73
-
74
- //xs size provided
75
- const svg = container.querySelector('svg');
76
- expect(svg).toHaveAttribute('width', '16px');
77
- });
78
- });
@@ -1,32 +0,0 @@
1
- import React from 'react';
2
- import {act, render} from '../../test-utils';
3
- import {BackButton} from '../index';
4
- import {Size} from '../../types'
5
- import 'jest-styled-components';
6
-
7
-
8
-
9
-
10
- describe('<BackButton />', () => {
11
- it('should render back button', function () {
12
- const {queryByText} = render(<BackButton size={Size.Small}>Back Button</BackButton>);
13
- expect(queryByText('Back Button')).toBeDefined();
14
- });
15
- it('should call action on click', function () {
16
- const clickMock = jest.fn(() => {});
17
- const component = render(<BackButton size={Size.Small} onClick={clickMock}>Back Button</BackButton>);
18
- act(() => {
19
- component.getByText('Back Button').click();
20
- });
21
- expect(clickMock).toBeCalled();
22
- });
23
- it('should not call action on click when disabled', function () {
24
- const clickMock = jest.fn(() => {});
25
- const component = render(<BackButton size={Size.Small} disabled={true} onClick={clickMock}>Back Button</BackButton>);
26
- act(() => {
27
- component.getByText('Back Button').click();
28
- });
29
- expect(clickMock).toBeCalledTimes(0);
30
- });
31
-
32
- });
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { render } from '../../test-utils';
3
- import { Button } from '../index';
4
- import 'jest-styled-components';
5
- import { COLORS } from '../../styles';
6
- import { Size } from '../..';
7
-
8
-
9
-
10
-
11
- describe('<Button />', () => {
12
- it('Renders primary button', async () => {
13
- const { queryByText, getByTestId } = render(
14
- <Button variant="primary" testId="TestButton" size={Size.Large}>
15
- TestButton
16
- </Button>,
17
- );
18
- expect(queryByText('TestButton')).toBeDefined();
19
- /*expect(getByTestId('TestButton')).toHaveStyleRule('background-color', COLORS.primary);
20
- expect(getByTestId('TestButton')).toHaveStyleRule('cursor', 'pointer');
21
- expect(getByTestId('TestButton')).toHaveStyleRule('color', 'white');*/
22
- });
23
- it('Renders secondary button', async () => {
24
- const { queryByText, getByTestId } = render(
25
- <Button variant="secondary" testId="TestButton">
26
- TestButton
27
- </Button>,
28
- );
29
- expect(queryByText('TestButton')).toBeDefined();
30
- /*expect(getByTestId('TestButton')).toHaveStyleRule('color', COLORS.primary);
31
- expect(getByTestId('TestButton')).toHaveStyleRule('border-color', COLORS.primary);
32
- expect(getByTestId('TestButton')).toHaveStyleRule('background-color', 'white');*/
33
- });
34
- it('Renders tertiary button', async () => {
35
- const { queryByText, getByTestId } = render(
36
- <Button variant="tertiary" testId="TestButton">
37
- TestButton
38
- </Button>,
39
- );
40
- expect(queryByText('TestButton')).toBeDefined();
41
- /*expect(getByTestId('TestButton')).toHaveStyleRule('background-color', 'white');
42
- expect(getByTestId('TestButton')).toHaveStyleRule('border-color', COLORS.neutral_100);
43
- expect(getByTestId('TestButton')).toHaveStyleRule('color', COLORS.primary);*/
44
- });
45
- });
@@ -1,119 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render } from '../../test-utils';
3
- import { DualFunctionButton } from '../index';
4
- import '@testing-library/jest-dom';
5
- import { Size, SystemIcons } from '../..';
6
- import 'jest-styled-components';
7
-
8
-
9
-
10
-
11
- describe('<DualButton />', () => {
12
- it('Renders checkbox button', async () => {
13
- const dropdownItems = [
14
- { value: 'Item 1', icon: undefined },
15
- { value: 'Item 2', icon: undefined, disabled: true },
16
- ];
17
- const { getByText, container, getByTestId } = render(
18
- <DualFunctionButton
19
- dropdownCustomizationProps={{
20
- items: dropdownItems,
21
- itemsType: 'checkbox',
22
- multiSelect: true,
23
- pinTopItem: true,
24
- actionLabel: 'Custom Action',
25
- action: () => {},
26
- onValueUpdate: (vals) => {},
27
- scrollable: true,
28
- }}
29
- id="test"
30
- size={Size.Small}
31
- variant="primary">
32
- Dual button checkbox test
33
- </DualFunctionButton>,
34
- );
35
- //expect button name defined
36
- expect(getByText('Dual button checkbox test')).toBeTruthy();
37
- //expect all items displayed
38
- expect(getByText('Item 1')).toBeTruthy();
39
- expect(getByText('Item 2')).toBeTruthy();
40
-
41
- //check that checkbox controls are displayed
42
- expect(getByText('Item 1').closest('label')).toHaveClass('checkbox-label');
43
- expect(getByText('Item 2').closest('label')).toHaveClass('checkbox-label');
44
-
45
- //expect item 2 to be disabled
46
- expect(getByText('Item 2').closest('div')).toHaveAttribute('disabled');
47
-
48
- //expect the toggle button to be defined
49
- expect(getByTestId('options_toggleBtn')).toBeTruthy();
50
-
51
- //expect select all displayed as pin top item is set as "true"
52
- expect(document.body.querySelector('[id*="checkbox_selectall"]')).toBeTruthy();
53
- });
54
-
55
- it('Renders normal dual button', async () => {
56
- const dropdownItems = [
57
- { value: 'Item 1', icon: undefined },
58
- { value: 'Item 2', icon: undefined },
59
- ];
60
- const { getByText, container, getByTestId } = render(
61
- <DualFunctionButton
62
- dropdownCustomizationProps={{
63
- items: dropdownItems,
64
- itemsType: 'normal',
65
- multiSelect: true,
66
- action: () => {},
67
- onValueUpdate: (vals) => {},
68
- scrollable: true,
69
- }}
70
- id="test"
71
- size={Size.Small}
72
- variant="primary">
73
- Dual button test
74
- </DualFunctionButton>,
75
- );
76
- //check that the dual button text defined
77
- expect(getByText('Dual button test')).toBeTruthy();
78
- expect(getByText('Item 1')).toBeTruthy();
79
- expect(getByText('Item 2')).toBeTruthy();
80
- //check that none of the items disabled
81
- expect(getByText('Item 1').closest('div')).not.toHaveAttribute('disabled');
82
- expect(getByText('Item 2').closest('div')).not.toHaveAttribute('disabled');
83
- expect(getByTestId('options_toggleBtn')).toBeTruthy();
84
-
85
- //two options available
86
- expect(document.body.querySelectorAll('button[tabindex="-1"]')).toHaveLength(2);
87
- });
88
-
89
- it('Renders radio-button type dual button', async () => {
90
- const dropdownItems = [
91
- { value: 'Item 1', icon: undefined, disabled: true },
92
- { value: 'Item 2', icon: undefined, disabled: true },
93
- ];
94
- const { getByText, container, getByTestId } = render(
95
- <DualFunctionButton
96
- dropdownCustomizationProps={{
97
- items: dropdownItems,
98
- itemsType: 'radio',
99
- multiSelect: true,
100
- action: () => {},
101
- onValueUpdate: (vals) => {},
102
- scrollable: true,
103
- }}
104
- id="test"
105
- size={Size.Small}
106
- variant="primary">
107
- Dual button test radio
108
- </DualFunctionButton>,
109
- );
110
- //check that the dual button text defined
111
- expect(getByText('Dual button test radio')).toBeTruthy();
112
- expect(getByText('Item 1')).toBeTruthy();
113
- expect(getByText('Item 2')).toBeTruthy();
114
-
115
- //check that radio buttons displayed
116
- expect(getByText('Item 1').closest('div')).toHaveClass('radio-button-label');
117
- expect(getByText('Item 2').closest('div')).toHaveClass('radio-button-label');
118
- });
119
- });
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import {act, render} from '../../../test-utils';
3
- import {
4
- HorizontalCard,
5
- HorizontalCardDropdownButton,
6
- HorizontalCardIconButton, HorizontalCardLinearProgression, HorizontalCardTag,
7
- HorizontalCardToggleButton
8
- } from '../index';
9
- import {SystemIcons} from '../../../icons';
10
-
11
-
12
-
13
- describe('HorizontalCard', () => {
14
- const action = jest.fn();
15
-
16
- const actions: (HorizontalCardIconButton | HorizontalCardToggleButton | HorizontalCardDropdownButton)[] = [
17
- {componentType: 'icon', action: action, icon: <SystemIcons.Share/>},
18
- {componentType: 'icon', action: action, icon: <SystemIcons.OpenNewWindow/>}
19
- ]
20
-
21
- const tags: HorizontalCardTag[] = [{label: 'label 1'}, {label: 'label 2'}, {label: 'label 3'}];
22
-
23
- const progress: HorizontalCardLinearProgression = {max: 100, value: 30};
24
-
25
- beforeEach(() => {
26
- action.mockReset();
27
- });
28
-
29
- it('should render title', async () => {
30
- const {queryByText} = render(<HorizontalCard title={'title'}/>)
31
-
32
- expect(queryByText('title')).toBeDefined()
33
- });
34
-
35
- it('should render tags', async () => {
36
-
37
- const {queryByText} = render(<HorizontalCard title={'title'} tags={tags}/>)
38
-
39
- expect(queryByText('label 1')).toBeDefined()
40
- expect(queryByText('label 2')).toBeDefined()
41
- expect(queryByText('label 3')).toBeDefined()
42
- });
43
-
44
- it('should render actions', async () => {
45
- const {container} = render(<HorizontalCard title={'title'} actions={actions}/>)
46
-
47
- expect(container.querySelectorAll('button')).toHaveLength(2)
48
- });
49
-
50
- it('should call action on component click', async () => {
51
- const {container} = render(<HorizontalCard title={'title'} action={action}/>)
52
-
53
- act(() => {
54
- // @ts-ignore
55
- container.querySelector('.clickable').click();
56
- });
57
-
58
- expect(action).toHaveBeenCalled()
59
- });
60
-
61
- it('should call action on button press', async () => {
62
- const {container} = render(<HorizontalCard title={'title'} actions={actions}/>)
63
-
64
- act(() => {
65
- container.querySelectorAll('button').forEach(a => a.click());
66
- });
67
-
68
- expect(action).toHaveBeenCalledTimes(2)
69
- });
70
-
71
- });
@@ -1,124 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, render } from '../../../test-utils';
3
- import 'jest-styled-components';
4
- import { Card } from '../..';
5
- import { COLORS } from '../../../styles';
6
- import { SystemIcons } from '../../../icons';
7
-
8
-
9
- describe('<Card />',()=>{
10
- it('renders top section', async () => {
11
- const{getByTestId} = render(
12
- <Card topSectionProps={{disabled: false}} disabled/>
13
- );
14
-
15
- expect(getByTestId('card-topSection')).toBeDefined();
16
- });
17
-
18
- it('renders middle section', async () => {
19
- const{getByTestId} = render(
20
- <Card middleSectionProps={{title:'title',disabled:false}} disabled/>
21
- );
22
-
23
- expect(getByTestId('card-middleSection')).toBeDefined();
24
- });
25
-
26
- it('renders bottom section', async () => {
27
- const{getByTestId} = render(
28
- <Card bottomSectionProps={{disabled:false}} disabled/>
29
- );
30
-
31
- expect(getByTestId('card-bottomSection')).toBeDefined();
32
- });
33
-
34
- it('fires card clicked event on click', async () => {
35
- const cardClicked = jest.fn();
36
- const{getByTestId} = render(
37
- <Card bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
38
- );
39
-
40
- fireEvent.click(getByTestId('card-wrapper'));
41
- expect(cardClicked).toBeCalledTimes(1);
42
- });
43
-
44
- it('fires card clicked event on keyDown', async () => {
45
- const cardClicked = jest.fn();
46
- const{getByTestId} = render(
47
- <Card bottomSectionProps={{disabled:false}} disabled={false} onCardClicked={cardClicked}/>
48
- );
49
-
50
- fireEvent.keyDown(getByTestId('card-wrapper'), {key: 'Enter', code: 'Enter', charCode: 13});
51
- expect(cardClicked).toBeCalledTimes(1);
52
- });
53
-
54
- it('renders tag in top section', async () => {
55
- const{getByText} = render(
56
- <Card topSectionProps={{disabled: false, tagLabel:'test_label'}} disabled/>
57
- );
58
-
59
- expect(getByText('test_label')).toBeDefined();
60
- });
61
-
62
- it('renders checkbox in top section', async () => {
63
- const{getByTestId} = render(
64
- <Card topSectionProps={{disabled: false, selected: true}} disabled/>
65
- );
66
-
67
- expect(getByTestId('card-topSection-checkbox')).toBeDefined();
68
- });
69
-
70
- it('renders highlight ribbon in top section', async () => {
71
- const{getByTestId, getByText} = render(
72
- <Card topSectionProps={{disabled: false, highlightRibbonText:'testRibbon', highlightRibbonBgColor:'red'}} disabled={false}/>
73
- );
74
-
75
- expect(getByText('testRibbon')).toBeDefined();
76
- expect(getByTestId('card-topSection-ribbon')).toHaveStyleRule('background-color','red');
77
- });
78
-
79
- it('renders title ,description and category label in middle section', async () => {
80
- const{getByText} = render(
81
- <Card middleSectionProps={{title:'testTitle', disabled: false, description:'testDescription', categoryLabel:'testCatLabel'}} disabled={false}/>
82
- );
83
-
84
- expect(getByText('testTitle')).toBeDefined();
85
- expect(getByText('testDescription')).toBeDefined();
86
- expect(getByText('testCatLabel')).toBeDefined();
87
- });
88
-
89
- it('renders tags in middle section', async () => {
90
- const{getByText} = render(
91
- <Card middleSectionProps={{title:'testTitle', disabled: false, tags:[{label:'testTag'}], row2Tags:[{label:'testTag2'}]}} disabled={false}/>
92
- );
93
-
94
- expect(getByText('testTitle')).toBeDefined();
95
- expect(getByText('testTag2')).toBeDefined();
96
- });
97
-
98
- it('renders note text in bottom section', async () => {
99
- const{getByText} = render(
100
- <Card bottomSectionProps={{disabled: false, noteLeft:'leftNote', noteRight:'rightNote'}} disabled={false}/>
101
- );
102
-
103
- expect(getByText('leftNote')).toBeDefined();
104
- expect(getByText('rightNote')).toBeDefined();
105
- });
106
-
107
- it('renders author in bottom section', async () => {
108
- const{getByText,getByTestId} = render(
109
- <Card bottomSectionProps={{disabled: true, authorName:'testAuthor'}} disabled={true}/>
110
- );
111
-
112
- expect(getByText('testAuthor')).toBeDefined();
113
- expect(getByTestId('card-bottomSection-author')).toBeDefined();
114
- });
115
-
116
- it('renders actions in bottom section', async () => {
117
- const{getByText,getByTestId} = render(
118
- <Card bottomSectionProps={{disabled: true, authorName:'testAuthor', actions:[{icon:<SystemIcons.Add/>,onClick:()=>{}}]}} disabled={true}/>
119
- );
120
-
121
- expect(getByText('testAuthor')).toBeDefined();
122
- expect(getByTestId('card-bottomSection-author')).toBeDefined();
123
- });
124
- })