@qoretechnologies/reqore 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/theme.d.ts +8 -1
- package/dist/constants/theme.d.ts.map +1 -1
- package/dist/constants/theme.js +16 -2
- package/dist/constants/theme.js.map +1 -1
- package/package.json +1 -1
- package/tests.json +1 -1
- package/.eslintrc.js +0 -40
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- package/.github/ISSUE_TEMPLATE/new-component.md +0 -20
- package/.github/ISSUE_TEMPLATE/visual-bug-report.md +0 -38
- package/.github/workflows/beta_release.yml +0 -100
- package/.github/workflows/tests.yml +0 -84
- package/.gitpod.yml +0 -11
- package/.jest-test-results.json +0 -1
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -0
- package/__tests__/breadcrumbs.test.tsx +0 -75
- package/__tests__/button.test.tsx +0 -218
- package/__tests__/checkbox.test.tsx +0 -45
- package/__tests__/collection.test.tsx +0 -243
- package/__tests__/containers/paging.test.tsx +0 -138
- package/__tests__/control_group.test.tsx +0 -32
- package/__tests__/drawer.test.tsx +0 -140
- package/__tests__/dropdown.test.tsx +0 -381
- package/__tests__/effect.test.tsx +0 -70
- package/__tests__/heading.test.tsx +0 -58
- package/__tests__/helpers/colors.test.tsx +0 -18
- package/__tests__/helpers/table.test.tsx +0 -67
- package/__tests__/hooks/useLatestZIndex.test.tsx +0 -10
- package/__tests__/hooks/useReqorePaging.test.tsx +0 -271
- package/__tests__/hooks/useTheme.test.tsx +0 -31
- package/__tests__/icon.test.tsx +0 -53
- package/__tests__/input.test.tsx +0 -482
- package/__tests__/layout.test.tsx +0 -37
- package/__tests__/menu.test.tsx +0 -65
- package/__tests__/messages.test.tsx +0 -79
- package/__tests__/modal.test.tsx +0 -204
- package/__tests__/multiselect.test.tsx +0 -458
- package/__tests__/navbar.test.tsx +0 -31
- package/__tests__/notifications.test.tsx +0 -178
- package/__tests__/pagination.test.tsx +0 -437
- package/__tests__/panel.test.tsx +0 -243
- package/__tests__/popover.test.tsx +0 -282
- package/__tests__/radiogroup.test.tsx +0 -47
- package/__tests__/setup.js +0 -8
- package/__tests__/stories/Collection.stories.tsx +0 -0
- package/__tests__/table.test.tsx +0 -647
- package/__tests__/tabs.test.tsx +0 -321
- package/__tests__/tag.test.tsx +0 -160
- package/__tests__/textarea.test.tsx +0 -467
- package/__tests__/timeAgo.test.tsx +0 -27
- package/__tests__/tree.test.tsx +0 -58
- package/build-storybook.log +0 -491
- package/chromatic.config.json +0 -1
- package/icons.ts +0 -1
- package/migration-storybook.log +0 -56
- package/public/logo-dark.png +0 -0
- package/public/logo.png +0 -0
- package/public/q-symbol-small.png +0 -0
- package/public/q-symbol.png +0 -0
- package/public/qoreLogo-dark.png +0 -0
- package/public/qoreLogo.png +0 -0
- package/src/components/Breadcrumbs/index.tsx +0 -254
- package/src/components/Breadcrumbs/item.tsx +0 -44
- package/src/components/Button/index.tsx +0 -633
- package/src/components/Checkbox/index.tsx +0 -388
- package/src/components/Collection/index.tsx +0 -426
- package/src/components/Collection/item.tsx +0 -267
- package/src/components/Columns/column.tsx +0 -27
- package/src/components/Columns/index.tsx +0 -41
- package/src/components/Comment/index.tsx +0 -141
- package/src/components/CommentFeed/index.tsx +0 -34
- package/src/components/Content/index.tsx +0 -34
- package/src/components/Content/wrapper.tsx +0 -36
- package/src/components/ControlGroup/index.tsx +0 -523
- package/src/components/DatePicker/index.tsx +0 -347
- package/src/components/Drawer/backdrop.tsx +0 -54
- package/src/components/Drawer/index.tsx +0 -365
- package/src/components/Dropdown/index.tsx +0 -153
- package/src/components/Dropdown/item.tsx +0 -33
- package/src/components/Dropdown/list.tsx +0 -222
- package/src/components/Effect/index.tsx +0 -464
- package/src/components/ExportModal/index.tsx +0 -99
- package/src/components/Header/index.tsx +0 -81
- package/src/components/Icon/index.tsx +0 -184
- package/src/components/Input/index.tsx +0 -295
- package/src/components/InputClearButton/index.tsx +0 -59
- package/src/components/InternalPopover/index.tsx +0 -303
- package/src/components/KeyValueTable/index.tsx +0 -192
- package/src/components/Label/index.tsx +0 -10
- package/src/components/Layout/content.tsx +0 -31
- package/src/components/Layout/index.tsx +0 -55
- package/src/components/Menu/divider.tsx +0 -92
- package/src/components/Menu/index.tsx +0 -141
- package/src/components/Menu/item.tsx +0 -137
- package/src/components/Menu/section.tsx +0 -81
- package/src/components/Message/index.tsx +0 -220
- package/src/components/Modal/index.tsx +0 -26
- package/src/components/MultiSelect/index.tsx +0 -288
- package/src/components/Navbar/divider.tsx +0 -50
- package/src/components/Navbar/group.tsx +0 -53
- package/src/components/Navbar/index.tsx +0 -82
- package/src/components/Navbar/item.tsx +0 -92
- package/src/components/Notifications/index.tsx +0 -57
- package/src/components/Notifications/notification.tsx +0 -362
- package/src/components/Paging/index.tsx +0 -321
- package/src/components/Panel/LabelEditor.tsx +0 -67
- package/src/components/Panel/NonResponsiveActions.tsx +0 -79
- package/src/components/Panel/__screenshots__/linux/panel-SomePanel.png +0 -0
- package/src/components/Panel/index.tsx +0 -912
- package/src/components/Panel/panel.screenshot.tsx +0 -29
- package/src/components/Paragraph/index.tsx +0 -43
- package/src/components/Popover/index.tsx +0 -68
- package/src/components/RadioGroup/index.tsx +0 -71
- package/src/components/Slider/index.tsx +0 -358
- package/src/components/Spacer/index.tsx +0 -142
- package/src/components/Spinner/index.tsx +0 -74
- package/src/components/Table/body.tsx +0 -109
- package/src/components/Table/cell.tsx +0 -136
- package/src/components/Table/header.tsx +0 -236
- package/src/components/Table/headerCell.tsx +0 -203
- package/src/components/Table/helpers.ts +0 -308
- package/src/components/Table/index.tsx +0 -797
- package/src/components/Table/row.tsx +0 -288
- package/src/components/Table/value.tsx +0 -28
- package/src/components/Tabs/content.tsx +0 -68
- package/src/components/Tabs/index.tsx +0 -124
- package/src/components/Tabs/item.tsx +0 -198
- package/src/components/Tabs/list.tsx +0 -381
- package/src/components/Tag/group.tsx +0 -73
- package/src/components/Tag/index.tsx +0 -463
- package/src/components/Textarea/index.tsx +0 -277
- package/src/components/TimeAgo/index.tsx +0 -15
- package/src/components/Tree/index.tsx +0 -271
- package/src/constants/animations.ts +0 -9
- package/src/constants/colors.ts +0 -13
- package/src/constants/paging.ts +0 -93
- package/src/constants/sizes.ts +0 -185
- package/src/constants/theme.ts +0 -122
- package/src/containers/Paging.tsx +0 -136
- package/src/containers/PopoverProvider.tsx +0 -124
- package/src/containers/ReqoreProvider.tsx +0 -289
- package/src/containers/ThemeProvider.tsx +0 -12
- package/src/containers/UIProvider.tsx +0 -101
- package/src/context/PopoverContext.tsx +0 -11
- package/src/context/ReqoreContext.tsx +0 -47
- package/src/context/ThemeContext.tsx +0 -4
- package/src/helpers/animations.ts +0 -13
- package/src/helpers/colors.ts +0 -335
- package/src/helpers/time.ts +0 -21
- package/src/helpers/utils.ts +0 -152
- package/src/hooks/useAutoFocus.ts +0 -106
- package/src/hooks/useCloneThroughFragments.ts +0 -39
- package/src/hooks/useCombinedRefs.ts +0 -26
- package/src/hooks/useLatestZIndex.ts +0 -13
- package/src/hooks/useOutsideClick.ts +0 -29
- package/src/hooks/usePaging.ts +0 -128
- package/src/hooks/usePopover.tsx +0 -220
- package/src/hooks/useQueryWithDelay.ts +0 -30
- package/src/hooks/useReqore.ts +0 -12
- package/src/hooks/useReqoreContext.ts +0 -16
- package/src/hooks/useReqoreEffect.ts +0 -49
- package/src/hooks/useTextareaAutoSize.ts +0 -22
- package/src/hooks/useTheme.ts +0 -48
- package/src/hooks/useTooltip.ts +0 -40
- package/src/hooks/useWhyDidYouUpdate.ts +0 -32
- package/src/icons.json +0 -2295
- package/src/index.tsx +0 -80
- package/src/mock/breadcrumbs.ts +0 -146
- package/src/mock/collectionData.tsx +0 -380
- package/src/mock/data.json +0 -11000
- package/src/mock/icons.ts +0 -32
- package/src/mock/menu.ts +0 -93
- package/src/mock/multiSelect.ts +0 -71
- package/src/mock/object.json +0 -317
- package/src/mock/styleMock.js +0 -1
- package/src/mock/tableData.ts +0 -64
- package/src/stories/Breadcrumbs/Breadcrumbs.stories.tsx +0 -27
- package/src/stories/Button/Button.stories.tsx +0 -405
- package/src/stories/Checkbox/Checkbox.stories.tsx +0 -75
- package/src/stories/Collection/Collection.stories.tsx +0 -317
- package/src/stories/Columns/Columns.stories.tsx +0 -158
- package/src/stories/Comment/Comment.stories.tsx +0 -136
- package/src/stories/ControlGroup/ControlGroup.stories.tsx +0 -399
- package/src/stories/DatePicker/DatePicker.stories.tsx +0 -348
- package/src/stories/Drawer/Drawer.stories.tsx +0 -294
- package/src/stories/Dropdown/Dropdown.stories.tsx +0 -375
- package/src/stories/Dropdown/DropdownTests.stories.tsx +0 -111
- package/src/stories/ExportModal/ExportModal.stories.tsx +0 -18
- package/src/stories/Header/Header.stories.tsx +0 -108
- package/src/stories/Icon/Icon.stories.tsx +0 -162
- package/src/stories/Input/Input.stories.tsx +0 -220
- package/src/stories/KeyValueTable/KeyValueTable.stories.tsx +0 -346
- package/src/stories/Label/Label.stories.tsx +0 -33
- package/src/stories/Menu/Menu.stories.tsx +0 -367
- package/src/stories/Message/Message.stories.tsx +0 -167
- package/src/stories/Modal/Manager.stories.tsx +0 -192
- package/src/stories/Modal/Modal.stories.tsx +0 -252
- package/src/stories/MultiSelect/MultiSelect.stories.tsx +0 -140
- package/src/stories/Navbar/Navbar.stories.tsx +0 -119
- package/src/stories/Notifications/Interactive.stories.tsx +0 -117
- package/src/stories/Notifications/Notification.stories.tsx +0 -216
- package/src/stories/Notifications/Notifications.stories.tsx +0 -81
- package/src/stories/Paging/Paging.stories.tsx +0 -255
- package/src/stories/Panel/Panel.stories.tsx +0 -753
- package/src/stories/Paragraph/Paragraph.stories.tsx +0 -108
- package/src/stories/Popover/Popover.stories.tsx +0 -510
- package/src/stories/RadioGroup/RadioGroup.stories.tsx +0 -212
- package/src/stories/Slider/Slider.stories.tsx +0 -173
- package/src/stories/Spacer/Spacer.stories.tsx +0 -100
- package/src/stories/Spinner/Spinner.stories.tsx +0 -82
- package/src/stories/Table/Table.stories.tsx +0 -571
- package/src/stories/Tabs/Tabs.stories.tsx +0 -346
- package/src/stories/Tag/Tag.stories.tsx +0 -381
- package/src/stories/Tag/TagGroup.stories.tsx +0 -307
- package/src/stories/TextArea/TextArea.stories.tsx +0 -287
- package/src/stories/TextArea/TextAreaTests.stories.tsx +0 -108
- package/src/stories/Tree/Tree.stories.tsx +0 -124
- package/src/stories/Wrapper.tsx +0 -13
- package/src/stories/utils/args.ts +0 -151
- package/src/stories/utils.ts +0 -39
- package/src/styles.ts +0 -124
- package/src/types/global.ts +0 -211
- package/src/types/icons.ts +0 -2272
- package/tsconfig.prod.json +0 -26
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getColumnsByPinType,
|
|
3
|
-
getColumnsCount,
|
|
4
|
-
getOnlyShownColumns,
|
|
5
|
-
hasHiddenColumns,
|
|
6
|
-
updateColumnData,
|
|
7
|
-
} from '../../src/components/Table/helpers';
|
|
8
|
-
import { testColumns } from '../../src/mock/tableData';
|
|
9
|
-
|
|
10
|
-
test('Updates top level column width', () => {
|
|
11
|
-
const columns = [...testColumns];
|
|
12
|
-
|
|
13
|
-
expect(columns[0].width).toBe(50);
|
|
14
|
-
|
|
15
|
-
const newColumns = updateColumnData(columns, 'id', 'resizedWidth', 100);
|
|
16
|
-
|
|
17
|
-
expect(newColumns[0].width).toBe(50);
|
|
18
|
-
expect(newColumns[0].resizedWidth).toBe(100);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('Updates group level column width', () => {
|
|
22
|
-
const columns = [...testColumns];
|
|
23
|
-
|
|
24
|
-
expect(columns[1].header!.columns![0].width).toBe(150);
|
|
25
|
-
|
|
26
|
-
const newColumns = updateColumnData(columns, 'firstName', 'resizedWidth', 250);
|
|
27
|
-
|
|
28
|
-
expect(newColumns[1].header!.columns![0].width).toBe(150);
|
|
29
|
-
expect(newColumns[1].header!.columns![0].resizedWidth).toBe(250);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('Filters out hidden columns', () => {
|
|
33
|
-
const columns = [...testColumns];
|
|
34
|
-
|
|
35
|
-
expect(getColumnsCount(columns)).toBe(8);
|
|
36
|
-
|
|
37
|
-
columns[1].header!.columns![0].show = false;
|
|
38
|
-
columns[1].header!.columns![1].show = false;
|
|
39
|
-
columns[3].show = false;
|
|
40
|
-
columns[4].header!.columns![1].show = false;
|
|
41
|
-
|
|
42
|
-
const newColumns = getOnlyShownColumns(columns);
|
|
43
|
-
|
|
44
|
-
expect(getColumnsCount(newColumns)).toBe(4);
|
|
45
|
-
expect(hasHiddenColumns(columns)).toBe(true);
|
|
46
|
-
expect(hasHiddenColumns(newColumns)).toBe(false);
|
|
47
|
-
expect(newColumns[1].dataId).toBe('address');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('Returns pinned columns', () => {
|
|
51
|
-
const columns = [...testColumns];
|
|
52
|
-
|
|
53
|
-
expect(getColumnsCount(columns)).toBe(8);
|
|
54
|
-
|
|
55
|
-
columns[1].header!.columns![1].pin = 'left';
|
|
56
|
-
columns[0].pin = 'left';
|
|
57
|
-
columns[4].header!.columns![0].pin = 'right';
|
|
58
|
-
columns[4].header!.columns![1].pin = 'right';
|
|
59
|
-
|
|
60
|
-
const leftPinColumns = getColumnsByPinType(columns, 'left');
|
|
61
|
-
const rightPinColumns = getColumnsByPinType(columns, 'right');
|
|
62
|
-
const mainColumns = getColumnsByPinType(columns, 'main');
|
|
63
|
-
|
|
64
|
-
expect(getColumnsCount(leftPinColumns)).toBe(2);
|
|
65
|
-
expect(getColumnsCount(rightPinColumns)).toBe(2);
|
|
66
|
-
expect(getColumnsCount(mainColumns)).toBe(4);
|
|
67
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { renderHook } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ReqoreUIProvider, useLatestZIndex } from '../../src';
|
|
4
|
-
|
|
5
|
-
test('useLatestZIndex returns incremental z indexes', () => {
|
|
6
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
7
|
-
const { result } = renderHook(() => useLatestZIndex(), { wrapper });
|
|
8
|
-
|
|
9
|
-
expect(result.current).toEqual(9002);
|
|
10
|
-
});
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { renderHook } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { act } from 'react-dom/test-utils';
|
|
4
|
-
import { ReqoreUIProvider, useReqorePaging } from '../../src';
|
|
5
|
-
import { IReqorePagingOptions } from '../../src/hooks/usePaging';
|
|
6
|
-
import { tableData as data } from '../../src/mock/tableData';
|
|
7
|
-
|
|
8
|
-
test('useReqorePaging returns all pages', () => {
|
|
9
|
-
const fn = jest.fn();
|
|
10
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
11
|
-
const { result } = renderHook(
|
|
12
|
-
({ items }) =>
|
|
13
|
-
useReqorePaging({
|
|
14
|
-
items,
|
|
15
|
-
onPageChange: fn,
|
|
16
|
-
}),
|
|
17
|
-
{ wrapper, initialProps: { items: data } }
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
expect(result.current.pages.length).toEqual(100);
|
|
21
|
-
expect(result.current.pageCount).toEqual(100);
|
|
22
|
-
expect(result.current.renderControls).toEqual(true);
|
|
23
|
-
expect(fn).not.toHaveBeenCalled();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('useReqorePaging with default start page', () => {
|
|
27
|
-
const fn = jest.fn();
|
|
28
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
29
|
-
const { result } = renderHook(
|
|
30
|
-
({ items }) =>
|
|
31
|
-
useReqorePaging({
|
|
32
|
-
items,
|
|
33
|
-
startPage: 11,
|
|
34
|
-
pagesToShow: 5,
|
|
35
|
-
onPageChange: fn,
|
|
36
|
-
}),
|
|
37
|
-
{ wrapper, initialProps: { items: data } }
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
expect(result.current.pageCount).toEqual(100);
|
|
41
|
-
expect(result.current.currentPage).toEqual(11);
|
|
42
|
-
expect(result.current.pages.length).toEqual(7);
|
|
43
|
-
expect(result.current.pages[0]).toEqual(1);
|
|
44
|
-
expect(result.current.pages[1]).toEqual(9);
|
|
45
|
-
expect(result.current.pages[5]).toEqual(13);
|
|
46
|
-
expect(result.current.pages[6]).toEqual(100);
|
|
47
|
-
expect(fn).toHaveBeenCalledWith(11, { isFirst: false, isLast: false });
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('useReqorePaging specified number of pages', () => {
|
|
51
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
52
|
-
const { result } = renderHook(
|
|
53
|
-
({ items }) =>
|
|
54
|
-
useReqorePaging({
|
|
55
|
-
items,
|
|
56
|
-
pagesToShow: 5,
|
|
57
|
-
}),
|
|
58
|
-
{ wrapper, initialProps: { items: data } }
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
expect(result.current.allPages.length).toEqual(100);
|
|
62
|
-
expect(result.current.pages!.length).toEqual(6);
|
|
63
|
-
expect(result.current.pages![0]).toEqual(1);
|
|
64
|
-
expect(result.current.pages![4]).toEqual(5);
|
|
65
|
-
|
|
66
|
-
act(() => {
|
|
67
|
-
result.current.setPage(8);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(result.current.pages![1]).toEqual(6);
|
|
71
|
-
expect(result.current.pages![5]).toEqual(10);
|
|
72
|
-
|
|
73
|
-
act(() => {
|
|
74
|
-
result.current.last();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
expect(result.current.pages![1]).toEqual(96);
|
|
78
|
-
expect(result.current.pages![5]).toEqual(100);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test('useReqorePaging returns 1 page when items are empty', () => {
|
|
82
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
83
|
-
const { result } = renderHook(
|
|
84
|
-
({ items }) =>
|
|
85
|
-
useReqorePaging({
|
|
86
|
-
items,
|
|
87
|
-
}),
|
|
88
|
-
{ wrapper, initialProps: { items: [] } }
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
expect(result.current.pages.length).toEqual(1);
|
|
92
|
-
expect(result.current.renderControls).toEqual(false);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test('useReqorePaging returns correct number of rounded pages', () => {
|
|
96
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
97
|
-
const { result } = renderHook(
|
|
98
|
-
({ itemsPerPage, items }) =>
|
|
99
|
-
useReqorePaging({
|
|
100
|
-
items,
|
|
101
|
-
itemsPerPage,
|
|
102
|
-
}),
|
|
103
|
-
{ wrapper, initialProps: { itemsPerPage: 13, items: data } }
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
expect(result.current.pages.length).toEqual(77);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('useReqorePaging returns items per page', () => {
|
|
110
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
111
|
-
const { result } = renderHook(
|
|
112
|
-
({ itemsPerPage, items }) =>
|
|
113
|
-
useReqorePaging({
|
|
114
|
-
items,
|
|
115
|
-
itemsPerPage,
|
|
116
|
-
}),
|
|
117
|
-
{ wrapper, initialProps: { itemsPerPage: 10, items: data } }
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
expect(result.current.pages.length).toEqual(100);
|
|
121
|
-
expect(result.current.items.length).toEqual(10);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
test('useReqorePaging returns new items and pages when size of data change, current page is set to 1', () => {
|
|
125
|
-
const fn = jest.fn();
|
|
126
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
127
|
-
const { result, rerender } = renderHook(
|
|
128
|
-
({ itemsPerPage, items }) =>
|
|
129
|
-
useReqorePaging({
|
|
130
|
-
items,
|
|
131
|
-
itemsPerPage,
|
|
132
|
-
onPageChange: fn,
|
|
133
|
-
}),
|
|
134
|
-
{ wrapper, initialProps: { itemsPerPage: 10, items: data } }
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
expect(result.current.pages.length).toEqual(100);
|
|
138
|
-
expect(result.current.items.length).toEqual(10);
|
|
139
|
-
|
|
140
|
-
act(() => {
|
|
141
|
-
result.current.setPage(5);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
expect(result.current.currentPage).toEqual(5);
|
|
145
|
-
|
|
146
|
-
rerender({ itemsPerPage: 15, items: data.slice(0, 30) });
|
|
147
|
-
|
|
148
|
-
expect(result.current.pages.length).toEqual(2);
|
|
149
|
-
expect(result.current.items.length).toEqual(15);
|
|
150
|
-
expect(result.current.currentPage).toEqual(1);
|
|
151
|
-
expect(fn).toHaveBeenCalledWith(1, { isFirst: true, isLast: false });
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
test('useReqorePaging does not return new items and pages when data change', () => {
|
|
155
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
156
|
-
const { result, rerender } = renderHook(
|
|
157
|
-
({ itemsPerPage, items }: IReqorePagingOptions<any>) =>
|
|
158
|
-
useReqorePaging({
|
|
159
|
-
items,
|
|
160
|
-
itemsPerPage,
|
|
161
|
-
}),
|
|
162
|
-
{ wrapper, initialProps: { itemsPerPage: 10, items: data } as IReqorePagingOptions<any> }
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
expect(result.current.pages.length).toEqual(100);
|
|
166
|
-
expect(result.current.items.length).toEqual(10);
|
|
167
|
-
|
|
168
|
-
act(() => {
|
|
169
|
-
result.current.setPage(5);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
rerender({ items: [...data] });
|
|
173
|
-
|
|
174
|
-
expect(result.current.pages.length).toEqual(100);
|
|
175
|
-
expect(result.current.items.length).toEqual(10);
|
|
176
|
-
expect(result.current.currentPage).toEqual(5);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
test('useReqorePaging page navigation works correctly', () => {
|
|
180
|
-
const fn = jest.fn();
|
|
181
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
182
|
-
const { result } = renderHook(
|
|
183
|
-
({ itemsPerPage, items }: IReqorePagingOptions<any>) =>
|
|
184
|
-
useReqorePaging({
|
|
185
|
-
items,
|
|
186
|
-
itemsPerPage,
|
|
187
|
-
infinite: true,
|
|
188
|
-
onPageChange: fn,
|
|
189
|
-
}),
|
|
190
|
-
{ wrapper, initialProps: { itemsPerPage: 10, items: data } as IReqorePagingOptions<any> }
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
expect(result.current.pages.length).toEqual(100);
|
|
194
|
-
expect(result.current.items.length).toEqual(10);
|
|
195
|
-
|
|
196
|
-
act(() => {
|
|
197
|
-
result.current.setPage(2);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
expect(result.current.currentPage).toEqual(2);
|
|
201
|
-
expect(fn).toHaveBeenLastCalledWith(2, { isFirst: false, isLast: false });
|
|
202
|
-
|
|
203
|
-
act(() => {
|
|
204
|
-
result.current.next();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
expect(result.current.currentPage).toEqual(3);
|
|
208
|
-
expect(fn).toHaveBeenLastCalledWith(3, { isFirst: false, isLast: false });
|
|
209
|
-
|
|
210
|
-
act(() => {
|
|
211
|
-
result.current.last();
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
expect(result.current.isLastPage).toEqual(true);
|
|
215
|
-
expect(result.current.currentPage).toEqual(100);
|
|
216
|
-
expect(fn).toHaveBeenLastCalledWith(100, { isFirst: false, isLast: true });
|
|
217
|
-
|
|
218
|
-
act(() => {
|
|
219
|
-
result.current.back();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
expect(result.current.currentPage).toEqual(99);
|
|
223
|
-
expect(fn).toHaveBeenLastCalledWith(99, { isFirst: false, isLast: false });
|
|
224
|
-
|
|
225
|
-
act(() => {
|
|
226
|
-
result.current.first();
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
expect(result.current.isFirstPage).toEqual(true);
|
|
230
|
-
expect(result.current.currentPage).toEqual(1);
|
|
231
|
-
expect(fn).toHaveBeenLastCalledWith(1, { isFirst: true, isLast: false });
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
test('useReqorePaging returns correct number of items with infinite loading', () => {
|
|
235
|
-
const wrapper = ({ children }: any) => <ReqoreUIProvider>{children}</ReqoreUIProvider>;
|
|
236
|
-
const { result } = renderHook(
|
|
237
|
-
({ itemsPerPage, items }: IReqorePagingOptions<any>) =>
|
|
238
|
-
useReqorePaging({
|
|
239
|
-
items,
|
|
240
|
-
itemsPerPage,
|
|
241
|
-
infinite: true,
|
|
242
|
-
}),
|
|
243
|
-
{ wrapper, initialProps: { itemsPerPage: 10, items: data } as IReqorePagingOptions<any> }
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
expect(result.current.pages.length).toEqual(100);
|
|
247
|
-
expect(result.current.items.length).toEqual(10);
|
|
248
|
-
|
|
249
|
-
act(() => {
|
|
250
|
-
result.current.setPage(2);
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
expect(result.current.pages.length).toEqual(100);
|
|
254
|
-
expect(result.current.items.length).toEqual(20);
|
|
255
|
-
|
|
256
|
-
act(() => {
|
|
257
|
-
result.current.setPage(5);
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
expect(result.current.items.length).toEqual(50);
|
|
261
|
-
expect(result.current.itemsLeft).toEqual(950);
|
|
262
|
-
expect(result.current.renderControls).toEqual(true);
|
|
263
|
-
|
|
264
|
-
act(() => {
|
|
265
|
-
result.current.last();
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
expect(result.current.items.length).toEqual(1000);
|
|
269
|
-
expect(result.current.itemsLeft).toEqual(0);
|
|
270
|
-
expect(result.current.renderControls).toEqual(false);
|
|
271
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { renderHook } from '@testing-library/react';
|
|
2
|
-
import { ReqoreColors } from '../../src';
|
|
3
|
-
import { DEFAULT_THEME } from '../../src/constants/theme';
|
|
4
|
-
import { useReqoreTheme } from '../../src/hooks/useTheme';
|
|
5
|
-
|
|
6
|
-
test('useReqoreTheme should return the default theme', () => {
|
|
7
|
-
const { result } = renderHook(() => useReqoreTheme());
|
|
8
|
-
|
|
9
|
-
expect(result.current).toEqual(DEFAULT_THEME);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test('useReqoreTheme should return modified main intent color, original color is preserved', () => {
|
|
13
|
-
const { result } = renderHook(() => useReqoreTheme('main', { main: 'info' }));
|
|
14
|
-
|
|
15
|
-
expect(result.current.main).toEqual(ReqoreColors.BLUE);
|
|
16
|
-
expect(result.current.originalMain).toEqual(ReqoreColors.DARK_THEME);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('useReqoreTheme should return modified main custom color, original color is preserved', () => {
|
|
20
|
-
const { result } = renderHook(() => useReqoreTheme('main', { main: '#7fbb26' }));
|
|
21
|
-
|
|
22
|
-
expect(result.current.main).toEqual('#7fbb26');
|
|
23
|
-
expect(result.current.originalMain).toEqual(ReqoreColors.DARK_THEME);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
test('useReqoreTheme should return modified main color if intent is passed, original color is preserved', () => {
|
|
27
|
-
const { result } = renderHook(() => useReqoreTheme('main', { main: '#7fbb26' }, 'info'));
|
|
28
|
-
|
|
29
|
-
expect(result.current.main).toEqual(ReqoreColors.BLUE);
|
|
30
|
-
expect(result.current.originalMain).toEqual(ReqoreColors.DARK_THEME);
|
|
31
|
-
});
|
package/__tests__/icon.test.tsx
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { ReqoreContent, ReqoreIcon, ReqoreLayoutContent, ReqoreUIProvider } from '../src';
|
|
4
|
-
|
|
5
|
-
test('Renders <Icon /> properly', () => {
|
|
6
|
-
render(
|
|
7
|
-
<ReqoreUIProvider>
|
|
8
|
-
<ReqoreLayoutContent>
|
|
9
|
-
<ReqoreContent>
|
|
10
|
-
<ReqoreIcon icon='AccountBoxFill' />
|
|
11
|
-
</ReqoreContent>
|
|
12
|
-
</ReqoreLayoutContent>
|
|
13
|
-
</ReqoreUIProvider>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
expect(document.querySelectorAll('.reqore-icon').length).toBe(1);
|
|
17
|
-
expect(document.querySelectorAll('svg').length).toBe(1);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('Renders empty <Icon /> if icon does not exist', () => {
|
|
21
|
-
render(
|
|
22
|
-
<ReqoreUIProvider>
|
|
23
|
-
<ReqoreLayoutContent>
|
|
24
|
-
<ReqoreContent>
|
|
25
|
-
{/*@ts-expect-error*/}
|
|
26
|
-
<ReqoreIcon icon='SomeNonExistingIcon' />
|
|
27
|
-
</ReqoreContent>
|
|
28
|
-
</ReqoreLayoutContent>
|
|
29
|
-
</ReqoreUIProvider>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
expect(document.querySelectorAll('.reqore-icon').length).toBe(1);
|
|
33
|
-
expect(document.querySelector('.reqore-icon').textContent).toBe('');
|
|
34
|
-
expect(document.querySelectorAll('svg').length).toBe(0);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('Tooltip on <Icon /> works', () => {
|
|
38
|
-
jest.useFakeTimers();
|
|
39
|
-
|
|
40
|
-
render(
|
|
41
|
-
<ReqoreUIProvider>
|
|
42
|
-
<ReqoreIcon icon='24HoursLine' tooltip='test' />
|
|
43
|
-
</ReqoreUIProvider>
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
expect(document.querySelectorAll('.reqore-popover-content').length).toBe(0);
|
|
47
|
-
|
|
48
|
-
fireEvent.mouseEnter(document.querySelectorAll('.reqore-icon')[0]);
|
|
49
|
-
|
|
50
|
-
jest.advanceTimersByTime(1);
|
|
51
|
-
|
|
52
|
-
expect(document.querySelectorAll('.reqore-popover-content').length).toBe(1);
|
|
53
|
-
});
|