@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,146 +0,0 @@
1
- import React from 'react';
2
- import { fireEvent, getByRole, 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
- describe('<Card />',()=>{
9
- it('renders top section', async () => {
10
- const{getByTestId} = render(
11
- <Card topSectionProps={{disabled: false}} disabled/>
12
- );
13
-
14
- expect(getByTestId('card-topSection')).toBeDefined();
15
- //expect(getByTestId('card-middleSection')).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
-
125
- it('fires leftButton click event on click', async () => {
126
- const leftButtonClicked = jest.fn();
127
- const{getByRole} = render(
128
- <Card bottomSectionProps={{disabled: true,
129
- authorName:'testAuthor',
130
- actions:[],
131
- leftButton: {
132
- variant: 'tertiary',
133
- buttonText: 'button',
134
- onClick: (e) => {
135
- e.stopPropagation();
136
- leftButtonClicked();
137
- }
138
- }
139
- }}
140
- disabled={true}/>
141
- );
142
-
143
- fireEvent.click(getByRole('button'));
144
- expect(leftButtonClicked).toBeCalledTimes(1);
145
- });
146
- })
@@ -1,94 +0,0 @@
1
- import * as React from 'react';
2
- import {ActionChip} from '../index';
3
- import {act, fireEvent, render} from '../../test-utils';
4
- import { SystemIcons } from '../../icons';
5
-
6
- describe('ActionChip', () => {
7
-
8
- it('should render', () => {
9
- const wrapper = render(<ActionChip text={'label'}/>);
10
-
11
- expect(wrapper.queryByText('label')).toBeInTheDocument();
12
- });
13
-
14
- it('should render icon', () => {
15
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>}/>);
16
-
17
- expect(wrapper.queryByLabelText('Book')).toBeInTheDocument();
18
- });
19
-
20
- it('should be focusable if it is not disabled and onClick is defined', () => {
21
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={jest.fn()}/>);
22
-
23
- expect(wrapper.container.querySelector('[tabindex="0"]')).toBeInTheDocument();
24
- });
25
-
26
- it('should not be focusable if it is disabled', () => {
27
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} disabled={true} onClick={jest.fn()}/>);
28
-
29
- expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
30
- });
31
-
32
- it('should not be focusable if it is not interactive', () => {
33
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>}/>);
34
-
35
- expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
36
- });
37
-
38
- it('should call onClick when its clicked', () => {
39
- const onClickSpy = jest.fn();
40
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={onClickSpy}/>);
41
-
42
- act(() => {
43
- wrapper.getByText('label').click();
44
- });
45
-
46
- expect(onClickSpy).toHaveBeenCalled();
47
- });
48
-
49
- it('should call onClick when Enter is pressed', () => {
50
- const onClickSpy = jest.fn();
51
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={onClickSpy}/>);
52
-
53
- act(() => {
54
- fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
55
- });
56
-
57
- expect(onClickSpy).toHaveBeenCalled();
58
- });
59
-
60
- it('should call onClick when Space is pressed', () => {
61
- const onClickSpy = jest.fn();
62
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} onClick={onClickSpy}/>);
63
-
64
- act(() => {
65
- fireEvent.keyDown(wrapper.getByText('label'), {key: ' '});
66
- });
67
-
68
- expect(onClickSpy).toHaveBeenCalled();
69
- });
70
-
71
- it('should not call onClick when its clicked if disabled', () => {
72
- const onClickSpy = jest.fn();
73
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} disabled={true} onClick={onClickSpy}/>);
74
-
75
- act(() => {
76
- wrapper.getByText('label').click();
77
- });
78
-
79
- expect(onClickSpy).not.toHaveBeenCalled();
80
- });
81
-
82
- it('should not call onClick when Enter is pressed if disabled', () => {
83
- const onClickSpy = jest.fn();
84
- const wrapper = render(<ActionChip text={'label'} icon={<SystemIcons.Book/>} disabled={true} onClick={onClickSpy}/>);
85
-
86
- act(() => {
87
- fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
88
- });
89
-
90
- expect(onClickSpy).not.toHaveBeenCalled();
91
- });
92
-
93
-
94
- });
@@ -1,79 +0,0 @@
1
- import * as React from 'react';
2
- import {ChoiceChips} from '../index';
3
- import {render, act, fireEvent} from '../../test-utils';
4
-
5
-
6
-
7
-
8
- describe('ChoiceChips', () => {
9
-
10
- it('should render chips', () => {
11
-
12
- const wrapper = render(<ChoiceChips selected={'1'}
13
- values={[{value: '1', label: 'label'}, {value: '2', label: 'label 2'}]}/>);
14
-
15
- expect(wrapper.queryAllByRole('radio')).toHaveLength(2);
16
- expect(wrapper.queryByText('label')).toBeInTheDocument();
17
- expect(wrapper.queryByText('label 2')).toBeInTheDocument();
18
- });
19
-
20
- it('should call onClick when chip is clicked', () => {
21
- const onClickSpy = jest.fn();
22
-
23
- const wrapper = render(<ChoiceChips selected={'1'}
24
- onClick={onClickSpy}
25
- values={[{value: '1', label: 'label'}, {value: '2', label: 'label 2'}]}/>);
26
-
27
- act(() => {
28
- wrapper.getByText('label 2').click()
29
- });
30
-
31
- expect(onClickSpy).toHaveBeenCalledWith({value: '2', label: 'label 2'});
32
- });
33
-
34
- it('should call onClick when enter is pressed on focused chip', () => {
35
- const onClickSpy = jest.fn();
36
-
37
- const wrapper = render(<ChoiceChips selected={'1'}
38
- onClick={onClickSpy}
39
- values={[{value: '1', label: 'label'}, {value: '2', label: 'label 2'}]}/>);
40
-
41
- act(() => {
42
- fireEvent.keyDown(wrapper.getByText('label 2'), {key: 'Enter', code: 'Enter'});
43
- });
44
-
45
- expect(onClickSpy).toHaveBeenCalledWith({value: '2', label: 'label 2'});
46
- });
47
-
48
- it('should not call onClick when chip is clicked if its disabled', () => {
49
- const onClickSpy = jest.fn();
50
-
51
- const wrapper = render(<ChoiceChips selected={'1'}
52
- disabled={true}
53
- onClick={onClickSpy}
54
- values={[{value: '1', label: 'label'}, {value: '2', label: 'label 2'}]}/>);
55
-
56
- act(() => {
57
- wrapper.getByText('label 2').click()
58
- });
59
-
60
- expect(onClickSpy).not.toHaveBeenCalled();
61
- });
62
-
63
- it('should render selected chip with default class others with outline class', () => {
64
- const onClickSpy = jest.fn();
65
-
66
- const wrapper = render(<ChoiceChips selected={'1'}
67
- onClick={onClickSpy}
68
- values={[{value: '1', label: 'label'}, {value: '2', label: 'label 2'}]}/>);
69
-
70
-
71
- act(() => {
72
- wrapper.getByText('label 2').click()
73
- });
74
-
75
- expect(wrapper.queryAllByRole('radio')[0]).toHaveClass('outline');
76
- expect(wrapper.queryAllByRole('radio')[1]).toHaveClass('default')
77
- });
78
-
79
- })
@@ -1,95 +0,0 @@
1
- import * as React from 'react';
2
- import {FilterChip} from '../index';
3
- import {act, fireEvent, render} from '../../test-utils';
4
-
5
-
6
-
7
-
8
- describe('FilterChip', () => {
9
-
10
- it('should render', () => {
11
- const wrapper = render(<FilterChip selected={false} text={'label'}/>);
12
-
13
- expect(wrapper.queryByText('label')).toBeInTheDocument();
14
- });
15
-
16
- it('should render icon when selected', () => {
17
- const wrapper = render(<FilterChip selected={true} text={'label'}/>);
18
-
19
- expect(wrapper.queryByLabelText('Checkmark')).toBeInTheDocument();
20
- });
21
-
22
- it('should be focusable if it is not disabled and onClick is defined', () => {
23
- const wrapper = render(<FilterChip selected={false} text={'label'} onClick={jest.fn()}/>);
24
-
25
- expect(wrapper.container.querySelector('[tabindex="0"]')).toBeInTheDocument();
26
- });
27
-
28
- it('should not be focusable if it is disabled', () => {
29
- const wrapper = render(<FilterChip selected={false} text={'label'} disabled={true} onClick={jest.fn()}/>);
30
-
31
- expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
32
- });
33
-
34
- it('should not be focusable if it is not interactive', () => {
35
- const wrapper = render(<FilterChip selected={false} text={'label'}/>);
36
-
37
- expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
38
- });
39
-
40
- it('should call onClick when its clicked', () => {
41
- const onClickSpy = jest.fn();
42
- const wrapper = render(<FilterChip selected={false} text={'label'} onClick={onClickSpy}/>);
43
-
44
- act(() => {
45
- wrapper.getByText('label').click();
46
- });
47
-
48
- expect(onClickSpy).toHaveBeenCalled();
49
- });
50
-
51
- it('should call onClick when Enter is pressed', () => {
52
- const onClickSpy = jest.fn();
53
- const wrapper = render(<FilterChip selected={false} text={'label'} onClick={onClickSpy}/>);
54
-
55
- act(() => {
56
- fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
57
- });
58
-
59
- expect(onClickSpy).toHaveBeenCalled();
60
- });
61
-
62
- it('should call onClick when Space is pressed', () => {
63
- const onClickSpy = jest.fn();
64
- const wrapper = render(<FilterChip selected={false} text={'label'} onClick={onClickSpy}/>);
65
-
66
- act(() => {
67
- fireEvent.keyDown(wrapper.getByText('label'), {key: ' ', code: 'Space'});
68
- });
69
-
70
- expect(onClickSpy).toHaveBeenCalled();
71
- });
72
-
73
- it('should not call onClick when its clicked if disabled', () => {
74
- const onClickSpy = jest.fn();
75
- const wrapper = render(<FilterChip selected={false} text={'label'} disabled={true} onClick={onClickSpy}/>);
76
-
77
- act(() => {
78
- wrapper.getByText('label').click();
79
- });
80
-
81
- expect(onClickSpy).not.toHaveBeenCalled();
82
- });
83
-
84
- it('should not call onClick when Enter is pressed if disabled', () => {
85
- const onClickSpy = jest.fn();
86
- const wrapper = render(<FilterChip selected={false} text={'label'} disabled={true} onClick={onClickSpy}/>);
87
-
88
- act(() => {
89
- fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
90
- });
91
-
92
- expect(onClickSpy).not.toHaveBeenCalled();
93
- });
94
-
95
- });
@@ -1,155 +0,0 @@
1
- import * as React from 'react';
2
- import {InputChip} from '../index';
3
- import {act, fireEvent, render} from '../../test-utils';
4
- import {States} from '../../types';
5
- import { SystemIcons } from '../../icons';
6
-
7
-
8
-
9
-
10
- describe('InputChip', () => {
11
-
12
- it('should render', () => {
13
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'}/>);
14
-
15
- expect(wrapper.queryByText('label')).toBeInTheDocument();
16
- });
17
-
18
- it('should render icon', () => {
19
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}/>);
20
-
21
- expect(wrapper.queryByLabelText('Book')).toBeInTheDocument();
22
- });
23
-
24
- it('should be focusable if it is not disabled and onClick is defined', () => {
25
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
26
- onClick={jest.fn()}/>);
27
-
28
- expect(wrapper.container.querySelector('[tabindex="0"]')).toBeInTheDocument();
29
- });
30
-
31
- it('should not be focusable if it is disabled', () => {
32
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
33
- disabled={true} onClick={jest.fn()}/>);
34
-
35
- expect(wrapper.container.querySelector('[tabindex="-1"]')).toBeInTheDocument();
36
- });
37
-
38
- it('should call onClick when its clicked', () => {
39
- const onClickSpy = jest.fn();
40
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
41
- onClick={onClickSpy}/>);
42
-
43
- act(() => {
44
- wrapper.getByText('label').click();
45
- });
46
-
47
- expect(onClickSpy).toHaveBeenCalled();
48
- });
49
-
50
- it('should call onClick when Enter is pressed', () => {
51
- const onClickSpy = jest.fn();
52
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
53
- onClick={onClickSpy}/>);
54
-
55
- act(() => {
56
- fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
57
- });
58
-
59
- expect(onClickSpy).toHaveBeenCalled();
60
- });
61
-
62
- it('should call onClick when Space is pressed', () => {
63
- const onClickSpy = jest.fn();
64
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
65
- onClick={onClickSpy}/>);
66
-
67
- act(() => {
68
- fireEvent.keyDown(wrapper.getByText('label'), {key: ' ', code: 'Space'});
69
- });
70
-
71
- expect(onClickSpy).toHaveBeenCalled();
72
- });
73
-
74
- it('should not call onClick when its clicked if disabled', () => {
75
- const onClickSpy = jest.fn();
76
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
77
- disabled={true} onClick={onClickSpy}/>);
78
-
79
- act(() => {
80
- wrapper.getByText('label').click();
81
- });
82
-
83
- expect(onClickSpy).not.toHaveBeenCalled();
84
- });
85
-
86
- it('should not call onClick when Enter is pressed if disabled', () => {
87
- const onClickSpy = jest.fn();
88
- const wrapper = render(<InputChip variant={States.Default} onRemove={jest.fn()} text={'label'} icon={<SystemIcons.Book/>}
89
- disabled={true} onClick={onClickSpy}/>);
90
-
91
- act(() => {
92
- fireEvent.keyDown(wrapper.getByText('label'), {key: 'Enter', code: 'Enter'});
93
- });
94
-
95
- expect(onClickSpy).not.toHaveBeenCalled();
96
- });
97
-
98
- it('should call onRemove when remove is clicked', () => {
99
- const onRemoveSpy = jest.fn();
100
- const wrapper = render(<InputChip variant={States.Default} onRemove={onRemoveSpy} text={'label'} icon={<SystemIcons.Book/>}/>);
101
-
102
- act(() => {
103
- fireEvent.click(wrapper.getByLabelText('Close'));
104
- });
105
-
106
- expect(onRemoveSpy).toHaveBeenCalled();
107
- });
108
-
109
- it('should call onRemove when Enter is pressed on remove button', () => {
110
- const onRemoveSpy = jest.fn();
111
- const wrapper = render(<InputChip variant={States.Default} onRemove={onRemoveSpy} text={'label'} icon={<SystemIcons.Book/>}/>);
112
-
113
- act(() => {
114
- fireEvent.keyDown(wrapper.getByLabelText('Close'), {key: 'Enter', code: 'Enter'});
115
- });
116
-
117
- expect(onRemoveSpy).toHaveBeenCalled();
118
- });
119
-
120
- it('should call onRemove when Space is pressed on remove button', () => {
121
- const onRemoveSpy = jest.fn();
122
- const wrapper = render(<InputChip variant={States.Default} onRemove={onRemoveSpy} text={'label'} icon={<SystemIcons.Book/>}/>);
123
-
124
- act(() => {
125
- fireEvent.keyDown(wrapper.getByLabelText('Close'), {key: ' ', code: 'Space'});
126
- });
127
-
128
- expect(onRemoveSpy).toHaveBeenCalled();
129
- });
130
-
131
- it('should not call onRemove when remove is clicked and its disabled', () => {
132
- const onRemoveSpy = jest.fn();
133
- const wrapper = render(<InputChip variant={States.Default} onRemove={onRemoveSpy} disabled={true} text={'label'}
134
- icon={<SystemIcons.Book/>}/>);
135
-
136
- act(() => {
137
- fireEvent.click(wrapper.getByLabelText('Close'));
138
- });
139
-
140
- expect(onRemoveSpy).not.toHaveBeenCalled();
141
- });
142
-
143
- it('should not call onRemove when Enter is pressed on remove button and it disabled', () => {
144
- const onRemoveSpy = jest.fn();
145
- const wrapper = render(<InputChip variant={States.Default} onRemove={onRemoveSpy} disabled={true} text={'label'}
146
- icon={<SystemIcons.Book/>}/>);
147
-
148
- act(() => {
149
- fireEvent.keyDown(wrapper.getByLabelText('Close'), {key: 'Enter', code: 'Enter'});
150
- });
151
-
152
- expect(onRemoveSpy).not.toHaveBeenCalled();
153
- });
154
-
155
- });
@@ -1,100 +0,0 @@
1
- import React from 'react';
2
- import {act, fireEvent, render, RenderResult} from '../../test-utils';
3
- import {ChipDropdownInput} from '../..';
4
- import '../../../jest.setup';
5
-
6
- const list = ['Contact', 'About', 'Base', 'Blog', 'Custom', 'Support', 'Tools'];
7
-
8
-
9
-
10
- describe('<ChipDropdownInput />', () => {
11
- it('Renders with no default values and no items available', async () => {
12
- let componentResult: RenderResult;
13
-
14
- //initial values are determined by using multiple hooks (useEffect)
15
- //in order to be sure we get the last rendered version of the component, we need to wait for it
16
- await act(async () => {
17
- componentResult = render(
18
- <ChipDropdownInput inputId="test_chip" list={[]} values={[]} onValueChange={(input) => {
19
- }} placeholder="Search" altPlaceholder="" messageOnNoResults="No results found"/>,
20
- );
21
- });
22
- //check correct placeholder displayed
23
- expect(componentResult!.getByPlaceholderText('Search') as HTMLInputElement).toBeTruthy();
24
- //check chip input with provided id rendered
25
- expect(componentResult!.container.querySelector('input[id="test_chip"]')).toBeTruthy();
26
- //check no initial value displayed
27
- expect((componentResult!.getByPlaceholderText('Search') as HTMLInputElement).value).toBe('');
28
- });
29
-
30
- it('Renders with default values and items available', async () => {
31
- let componentResult: RenderResult;
32
- await act(async () => {
33
- componentResult = render(
34
- <ChipDropdownInput
35
- inputId="test_chip"
36
- list={list}
37
- values={['Support']}
38
- onValueChange={(input) => {
39
- }}
40
- placeholder="Search"
41
- altPlaceholder="Type to search"
42
- messageOnNoResults="No results found"
43
- />,
44
- );
45
- });
46
- //check alt placeholder displayed when list values
47
- expect(componentResult!.getByPlaceholderText('Type to search') as HTMLInputElement).toBeTruthy();
48
- //check correct initial value displayed
49
- expect(componentResult!.getByText('Support')).toBeTruthy();
50
- });
51
-
52
- it('Renders dropdown on input click', async () => {
53
- const wrapper = render(
54
- <ChipDropdownInput
55
- inputId="test_chip"
56
- list={list}
57
- values={['Support']}
58
- onValueChange={(input) => {
59
- }}
60
- placeholder="Search"
61
- altPlaceholder="Type to search"
62
- messageOnNoResults="No results found"
63
- />,
64
- );
65
-
66
- act(() => {
67
- fireEvent.click(wrapper.getByPlaceholderText('Type to search'));
68
- });
69
-
70
- expect(wrapper.container.querySelector('.show')).toBeInTheDocument();
71
- });
72
-
73
- it('Renders dropdown and items are filtered by search criteria', () => {
74
- const changeMock = jest.fn();
75
-
76
- const wrapper = render(
77
- <ChipDropdownInput
78
- inputId="test_chip"
79
- list={list}
80
- values={[]}
81
- onValueChange={changeMock}
82
- placeholder="Search"
83
- altPlaceholder="Type to search"
84
- messageOnNoResults="No results found"
85
- />,
86
- );
87
-
88
- act(() => {
89
- fireEvent.change(wrapper.getByPlaceholderText('Search'), {target: {value: 'b'}});
90
- });
91
-
92
- list.filter((item) => item.toLowerCase().includes('b')).forEach((item) => {
93
- expect(wrapper.queryByText(item)).toBeInTheDocument();
94
- });
95
-
96
- list.filter((item) => !item.toLowerCase().includes('b')).forEach((item) => {
97
- expect(wrapper.queryByText(item)).not.toBeInTheDocument();
98
- });
99
- });
100
- });