@coveord/plasma-mantine 49.2.2 → 49.2.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.
- package/.eslintrc.js +9 -4
- package/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +35 -31
- package/{src/components/code-editor/__mocks__ → __mocks__}/@monaco-editor/react.tsx +6 -8
- package/{src/components/code-editor/__mocks__ → __mocks__}/monaco-editor.ts +0 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/__tests__/Utils.js.map +1 -1
- package/dist/cjs/__tests__/VitestSetup.js +35 -0
- package/dist/cjs/__tests__/VitestSetup.js.map +1 -0
- package/dist/cjs/components/table/Th.js +8 -11
- package/dist/cjs/components/table/Th.js.map +1 -1
- package/dist/definitions/__tests__/Utils.d.ts +1 -1
- package/dist/definitions/__tests__/Utils.d.ts.map +1 -1
- package/dist/definitions/__tests__/VitestSetup.d.ts +2 -0
- package/dist/definitions/__tests__/VitestSetup.d.ts.map +1 -0
- package/dist/definitions/components/table/Th.d.ts.map +1 -1
- package/dist/esm/__tests__/Utils.js +1 -1
- package/dist/esm/__tests__/Utils.js.map +1 -1
- package/dist/esm/__tests__/VitestSetup.js +30 -0
- package/dist/esm/__tests__/VitestSetup.js.map +1 -0
- package/dist/esm/components/table/Th.js +9 -12
- package/dist/esm/components/table/Th.js.map +1 -1
- package/package.json +7 -6
- package/src/__tests__/Utils.tsx +1 -1
- package/src/__tests__/VitestSetup.ts +27 -0
- package/src/components/code-editor/__tests__/CodeEditor.spec.tsx +7 -5
- package/src/components/collection/__tests__/Collection.spec.tsx +2 -2
- package/src/components/date-range-picker/__tests__/DateRangePickerInlineCalendar.spec.tsx +17 -17
- package/src/components/date-range-picker/__tests__/DateRangePickerPopoverCalendar.spec.tsx +11 -7
- package/src/components/date-range-picker/__tests__/DateRangePickerPresetSelect.spec.tsx +1 -1
- package/src/components/inline-confirm/__tests__/InlineConfirm.spec.tsx +6 -6
- package/src/components/modal/__tests__/Modal.spec.tsx +3 -3
- package/src/components/modal-wizard/__tests__/ModalWizard.spec.tsx +8 -8
- package/src/components/prompt/__tests__/Prompt.spec.tsx +2 -2
- package/src/components/table/Th.tsx +9 -7
- package/src/components/table/__tests__/Table.spec.tsx +1 -1
- package/src/components/table/__tests__/TableActions.spec.tsx +1 -1
- package/src/components/table/__tests__/TableDateRangePicker.spec.tsx +11 -8
- package/src/components/table/__tests__/TableFilter.spec.tsx +4 -4
- package/src/components/table/__tests__/TablePagination.spec.tsx +2 -2
- package/src/components/table/__tests__/TablePerPage.spec.tsx +3 -3
- package/src/components/table/__tests__/TablePredicate.spec.tsx +2 -2
- package/src/components/table/__tests__/Th.spec.tsx +6 -15
- package/src/hooks/__tests__/useControlledList.spec.tsx +1 -1
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +3 -2
- package/vitest.config.ts +24 -0
- package/dist/cjs/__tests__/GlobalSetup.js +0 -17
- package/dist/cjs/__tests__/GlobalSetup.js.map +0 -1
- package/dist/cjs/__tests__/Setup.js +0 -6
- package/dist/cjs/__tests__/Setup.js.map +0 -1
- package/dist/cjs/__tests__/SetupAfterEnv.js +0 -19
- package/dist/cjs/__tests__/SetupAfterEnv.js.map +0 -1
- package/dist/cjs/components/code-editor/__mocks__/@monaco-editor/react.js +0 -45
- package/dist/cjs/components/code-editor/__mocks__/@monaco-editor/react.js.map +0 -1
- package/dist/cjs/components/code-editor/__mocks__/monaco-editor.js +0 -24
- package/dist/cjs/components/code-editor/__mocks__/monaco-editor.js.map +0 -1
- package/dist/definitions/__tests__/GlobalSetup.d.ts +0 -3
- package/dist/definitions/__tests__/GlobalSetup.d.ts.map +0 -1
- package/dist/definitions/__tests__/Setup.d.ts +0 -5
- package/dist/definitions/__tests__/Setup.d.ts.map +0 -1
- package/dist/definitions/__tests__/SetupAfterEnv.d.ts +0 -7
- package/dist/definitions/__tests__/SetupAfterEnv.d.ts.map +0 -1
- package/dist/definitions/components/code-editor/__mocks__/@monaco-editor/react.d.ts +0 -10
- package/dist/definitions/components/code-editor/__mocks__/@monaco-editor/react.d.ts.map +0 -1
- package/dist/definitions/components/code-editor/__mocks__/monaco-editor.d.ts +0 -8
- package/dist/definitions/components/code-editor/__mocks__/monaco-editor.d.ts.map +0 -1
- package/dist/esm/__tests__/GlobalSetup.js +0 -7
- package/dist/esm/__tests__/GlobalSetup.js.map +0 -1
- package/dist/esm/__tests__/Setup.js +0 -5
- package/dist/esm/__tests__/Setup.js.map +0 -1
- package/dist/esm/__tests__/SetupAfterEnv.js +0 -15
- package/dist/esm/__tests__/SetupAfterEnv.js.map +0 -1
- package/dist/esm/components/code-editor/__mocks__/@monaco-editor/react.js +0 -24
- package/dist/esm/components/code-editor/__mocks__/@monaco-editor/react.js.map +0 -1
- package/dist/esm/components/code-editor/__mocks__/monaco-editor.js +0 -14
- package/dist/esm/components/code-editor/__mocks__/monaco-editor.js.map +0 -1
- package/jest.config.js +0 -26
- package/src/__tests__/GlobalSetup.ts +0 -5
- package/src/__tests__/Setup.ts +0 -4
- package/src/__tests__/SetupAfterEnv.ts +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/__tests__/Utils.tsx"],"sourcesContent":["import {render, RenderOptions, RenderResult} from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport {FunctionComponent, PropsWithChildren, ReactElement} from 'react';\n\nimport {Plasmantine} from '../theme';\n\nconst customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult => {\n const TestWrapper: FunctionComponent<PropsWithChildren> = ({children}) => <Plasmantine>{children}</Plasmantine>;\n\n return render(ui, {wrapper: TestWrapper, ...options});\n};\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/Utils.tsx"],"sourcesContent":["import {render, RenderOptions, RenderResult} from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport {FunctionComponent, PropsWithChildren, ReactElement} from 'react';\n\nimport {Plasmantine} from '../theme';\n\nconst customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult => {\n const TestWrapper: FunctionComponent<PropsWithChildren> = ({children}) => <Plasmantine>{children}</Plasmantine>;\n\n return render(ui, {wrapper: TestWrapper, ...options});\n};\n\nexport * from '@testing-library/react';\nexport {userEvent};\nexport {customRender as render};\n"],"names":["userEvent","render","customRender","ui","options","TestWrapper","children","Plasmantine","wrapper"],"mappings":";;;;;;;;;;;IAaQA,SAAS;eAATA,kBAAS;;IACOC,MAAM;eAAtBC;;;;;;;iCAd0C;8DAC5B;qBAGI;AAE1B,IAAMA,eAAe,SAACC,IAAkBC,SAA2D;IAC/F,IAAMC,cAAoD;YAAEC,iBAAAA;6BAAc,qBAACC,kBAAW;sBAAED;;;IAExF,OAAOL,IAAAA,aAAM,EAACE,IAAI;QAACK,SAASH;OAAgBD;AAChD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
var _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
|
|
6
|
+
var _matchers = /*#__PURE__*/ _interopRequireDefault(require("@testing-library/jest-dom/matchers"));
|
|
7
|
+
var _react = require("@testing-library/react");
|
|
8
|
+
expect.extend(_matchers.default);
|
|
9
|
+
Object.defineProperty(window, "matchMedia", {
|
|
10
|
+
writable: true,
|
|
11
|
+
value: vi.fn().mockImplementation(function(query) {
|
|
12
|
+
return {
|
|
13
|
+
matches: false,
|
|
14
|
+
media: query,
|
|
15
|
+
onchange: null,
|
|
16
|
+
addListener: vi.fn(),
|
|
17
|
+
removeListener: vi.fn(),
|
|
18
|
+
addEventListener: vi.fn(),
|
|
19
|
+
removeEventListener: vi.fn(),
|
|
20
|
+
dispatchEvent: vi.fn()
|
|
21
|
+
};
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
window.ResizeObserver = window.ResizeObserver || vi.fn().mockImplementation(function() {
|
|
25
|
+
return {
|
|
26
|
+
disconnect: vi.fn(),
|
|
27
|
+
observe: vi.fn(),
|
|
28
|
+
unobserve: vi.fn()
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
afterEach(function() {
|
|
32
|
+
(0, _react.cleanup)();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=VitestSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/VitestSetup.ts"],"sourcesContent":["import matchers from '@testing-library/jest-dom/matchers';\nimport {cleanup} from '@testing-library/react';\nexpect.extend(matchers);\nObject.defineProperty(window, 'matchMedia', {\n writable: true,\n value: vi.fn().mockImplementation((query) => ({\n matches: false,\n media: query,\n onchange: null,\n addListener: vi.fn(), // deprecated\n removeListener: vi.fn(), // deprecated\n addEventListener: vi.fn(),\n removeEventListener: vi.fn(),\n dispatchEvent: vi.fn(),\n })),\n});\nwindow.ResizeObserver =\n window.ResizeObserver ||\n vi.fn().mockImplementation(() => ({\n disconnect: vi.fn(),\n observe: vi.fn(),\n unobserve: vi.fn(),\n }));\n\nafterEach(() => {\n cleanup();\n});\n"],"names":["expect","extend","matchers","Object","defineProperty","window","writable","value","vi","fn","mockImplementation","query","matches","media","onchange","addListener","removeListener","addEventListener","removeEventListener","dispatchEvent","ResizeObserver","disconnect","observe","unobserve","afterEach","cleanup"],"mappings":";;;;;6DAAqB;qBACC;AACtBA,OAAOC,MAAM,CAACC,iBAAQ;AACtBC,OAAOC,cAAc,CAACC,QAAQ,cAAc;IACxCC,UAAU,IAAI;IACdC,OAAOC,GAAGC,EAAE,GAAGC,kBAAkB,CAAC,SAACC;eAAW;YAC1CC,SAAS,KAAK;YACdC,OAAOF;YACPG,UAAU,IAAI;YACdC,aAAaP,GAAGC,EAAE;YAClBO,gBAAgBR,GAAGC,EAAE;YACrBQ,kBAAkBT,GAAGC,EAAE;YACvBS,qBAAqBV,GAAGC,EAAE;YAC1BU,eAAeX,GAAGC,EAAE;QACxB;;AACJ;AACAJ,OAAOe,cAAc,GACjBf,OAAOe,cAAc,IACrBZ,GAAGC,EAAE,GAAGC,kBAAkB,CAAC;WAAO;QAC9BW,YAAYb,GAAGC,EAAE;QACjBa,SAASd,GAAGC,EAAE;QACdc,WAAWf,GAAGC,EAAE;IACpB;;AAEJe,UAAU,WAAM;IACZC,IAAAA,cAAO;AACX"}
|
|
@@ -31,12 +31,14 @@ var useStyles = (0, _core.createStyles)(function(theme) {
|
|
|
31
31
|
};
|
|
32
32
|
});
|
|
33
33
|
var SortingIcons = {
|
|
34
|
-
asc: _plasmaReactIcons.
|
|
35
|
-
desc: _plasmaReactIcons.
|
|
34
|
+
asc: _plasmaReactIcons.ArrowUpSize16Px,
|
|
35
|
+
desc: _plasmaReactIcons.ArrowDownSize16Px,
|
|
36
|
+
none: _plasmaReactIcons.DoubleArrowHeadVSize16Px
|
|
36
37
|
};
|
|
37
38
|
var SortingLabels = {
|
|
38
39
|
asc: "ascending",
|
|
39
|
-
desc: "descending"
|
|
40
|
+
desc: "descending",
|
|
41
|
+
none: "none"
|
|
40
42
|
};
|
|
41
43
|
var Th = function(param) {
|
|
42
44
|
var header = param.header;
|
|
@@ -61,14 +63,14 @@ var Th = function(param) {
|
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
var onSort = header.column.getToggleSortingHandler();
|
|
64
|
-
var sortingOrder = header.column.getIsSorted();
|
|
65
|
-
var Icon = SortingIcons[sortingOrder
|
|
66
|
+
var sortingOrder = header.column.getIsSorted() || "none";
|
|
67
|
+
var Icon = SortingIcons[sortingOrder];
|
|
66
68
|
return /*#__PURE__*/ (0, _jsxRuntime.jsx)("th", {
|
|
67
69
|
className: classes.th,
|
|
68
70
|
style: {
|
|
69
71
|
width: width
|
|
70
72
|
},
|
|
71
|
-
"aria-sort":
|
|
73
|
+
"aria-sort": SortingLabels[sortingOrder],
|
|
72
74
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.UnstyledButton, {
|
|
73
75
|
onClick: onSort,
|
|
74
76
|
className: classes.control,
|
|
@@ -81,11 +83,6 @@ var Th = function(param) {
|
|
|
81
83
|
children: (0, _reactTable.flexRender)(header.column.columnDef.header, header.getContext())
|
|
82
84
|
}),
|
|
83
85
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_core.Center, {
|
|
84
|
-
sx: function(theme) {
|
|
85
|
-
return {
|
|
86
|
-
color: sortingOrder ? theme.colors.action[8] : undefined
|
|
87
|
-
};
|
|
88
|
-
},
|
|
89
86
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Icon, {
|
|
90
87
|
height: 14
|
|
91
88
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/table/Th.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/Th.tsx"],"sourcesContent":["import {ArrowDownSize16Px, ArrowUpSize16Px, DoubleArrowHeadVSize16Px} from '@coveord/plasma-react-icons';\nimport {Center, createStyles, Group, Text, UnstyledButton} from '@mantine/core';\nimport {defaultColumnSizing, flexRender, Header} from '@tanstack/react-table';\n\nconst useStyles = createStyles((theme) => ({\n th: {\n fontWeight: '400 !important' as any,\n padding: '0 !important',\n color: theme.black + '!important',\n verticalAlign: 'middle',\n },\n\n control: {\n width: '100%',\n padding: `${theme.spacing.xs}px ${theme.spacing.sm}px`,\n whiteSpace: 'nowrap',\n\n '&:hover': {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.gray[6] : theme.colors.gray[2],\n },\n },\n}));\n\ninterface ThProps<T> {\n header: Header<T, unknown>;\n}\n\nconst SortingIcons = {\n asc: ArrowUpSize16Px,\n desc: ArrowDownSize16Px,\n none: DoubleArrowHeadVSize16Px,\n};\n\nconst SortingLabels = {\n asc: 'ascending',\n desc: 'descending',\n none: 'none',\n} as const;\n\nexport const Th = <T,>({header}: ThProps<T>) => {\n const {classes} = useStyles();\n const size = header.column.getSize();\n const width = size !== defaultColumnSizing.size ? size : undefined;\n\n if (header.isPlaceholder) {\n return null;\n }\n\n if (!header.column.getCanSort()) {\n return (\n <th className={classes.th} style={{width}}>\n <Text size=\"xs\" py=\"xs\" px=\"sm\">\n {flexRender(header.column.columnDef.header, header.getContext())}\n </Text>\n </th>\n );\n }\n\n const onSort = header.column.getToggleSortingHandler();\n const sortingOrder = header.column.getIsSorted() || 'none';\n const Icon = SortingIcons[sortingOrder];\n\n return (\n <th className={classes.th} style={{width}} aria-sort={SortingLabels[sortingOrder]}>\n <UnstyledButton onClick={onSort} className={classes.control}>\n <Group position=\"apart\" noWrap>\n <Text size=\"xs\">{flexRender(header.column.columnDef.header, header.getContext())}</Text>\n <Center>\n <Icon height={14} />\n </Center>\n </Group>\n </UnstyledButton>\n </th>\n );\n};\n"],"names":["Th","useStyles","createStyles","theme","th","fontWeight","padding","color","black","verticalAlign","control","width","spacing","xs","sm","whiteSpace","backgroundColor","colorScheme","colors","gray","SortingIcons","asc","ArrowUpSize16Px","desc","ArrowDownSize16Px","none","DoubleArrowHeadVSize16Px","SortingLabels","header","classes","size","column","getSize","defaultColumnSizing","undefined","isPlaceholder","getCanSort","className","style","Text","py","px","flexRender","columnDef","getContext","onSort","getToggleSortingHandler","sortingOrder","getIsSorted","Icon","aria-sort","UnstyledButton","onClick","Group","position","noWrap","Center","height"],"mappings":";;;;+BAuCaA;;;eAAAA;;;;gCAvC8D;oBACX;0BACV;AAEtD,IAAMC,YAAYC,IAAAA,kBAAY,EAAC,SAACC;WAAW;QACvCC,IAAI;YACAC,YAAY;YACZC,SAAS;YACTC,OAAOJ,MAAMK,KAAK,GAAG;YACrBC,eAAe;QACnB;QAEAC,SAAS;YACLC,OAAO;YACPL,SAAS,AAAC,GAAwBH,OAAtBA,MAAMS,OAAO,CAACC,EAAE,EAAC,OAAsB,OAAjBV,MAAMS,OAAO,CAACE,EAAE,EAAC;YACnDC,YAAY;YAEZ,WAAW;gBACPC,iBAAiBb,MAAMc,WAAW,KAAK,SAASd,MAAMe,MAAM,CAACC,IAAI,CAAC,EAAE,GAAGhB,MAAMe,MAAM,CAACC,IAAI,CAAC,EAAE;YAC/F;QACJ;IACJ;;AAMA,IAAMC,eAAe;IACjBC,KAAKC,iCAAe;IACpBC,MAAMC,mCAAiB;IACvBC,MAAMC,0CAAwB;AAClC;AAEA,IAAMC,gBAAgB;IAClBN,KAAK;IACLE,MAAM;IACNE,MAAM;AACV;AAEO,IAAMzB,KAAK,gBAA8B;QAAxB4B,eAAAA;IACpB,IAAM,AAACC,UAAW5B,YAAX4B;IACP,IAAMC,OAAOF,OAAOG,MAAM,CAACC,OAAO;IAClC,IAAMrB,QAAQmB,SAASG,+BAAmB,CAACH,IAAI,GAAGA,OAAOI,SAAS;IAElE,IAAIN,OAAOO,aAAa,EAAE;QACtB,OAAO,IAAI;IACf,CAAC;IAED,IAAI,CAACP,OAAOG,MAAM,CAACK,UAAU,IAAI;QAC7B,qBACI,qBAAChC;YAAGiC,WAAWR,QAAQzB,EAAE;YAAEkC,OAAO;gBAAC3B,OAAAA;YAAK;sBACpC,cAAA,qBAAC4B,UAAI;gBAACT,MAAK;gBAAKU,IAAG;gBAAKC,IAAG;0BACtBC,IAAAA,sBAAU,EAACd,OAAOG,MAAM,CAACY,SAAS,CAACf,MAAM,EAAEA,OAAOgB,UAAU;;;IAI7E,CAAC;IAED,IAAMC,SAASjB,OAAOG,MAAM,CAACe,uBAAuB;IACpD,IAAMC,eAAenB,OAAOG,MAAM,CAACiB,WAAW,MAAM;IACpD,IAAMC,OAAO7B,YAAY,CAAC2B,aAAa;IAEvC,qBACI,qBAAC3C;QAAGiC,WAAWR,QAAQzB,EAAE;QAAEkC,OAAO;YAAC3B,OAAAA;QAAK;QAAGuC,aAAWvB,aAAa,CAACoB,aAAa;kBAC7E,cAAA,qBAACI,oBAAc;YAACC,SAASP;YAAQR,WAAWR,QAAQnB,OAAO;sBACvD,cAAA,sBAAC2C,WAAK;gBAACC,UAAS;gBAAQC,MAAM;;kCAC1B,qBAAChB,UAAI;wBAACT,MAAK;kCAAMY,IAAAA,sBAAU,EAACd,OAAOG,MAAM,CAACY,SAAS,CAACf,MAAM,EAAEA,OAAOgB,UAAU;;kCAC7E,qBAACY,YAAM;kCACH,cAAA,qBAACP;4BAAKQ,QAAQ;;;;;;;AAMtC"}
|
|
@@ -2,7 +2,7 @@ import { RenderOptions, RenderResult } from '@testing-library/react';
|
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
import { ReactElement } from 'react';
|
|
4
4
|
declare const customRender: (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>) => RenderResult;
|
|
5
|
-
export { userEvent };
|
|
6
5
|
export * from '@testing-library/react';
|
|
6
|
+
export { userEvent };
|
|
7
7
|
export { customRender as render };
|
|
8
8
|
//# sourceMappingURL=Utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/Utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAE,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAC3E,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAuC,YAAY,EAAC,MAAM,OAAO,CAAC;AAIzE,QAAA,MAAM,YAAY,OAAQ,YAAY,YAAY,KAAK,aAAa,EAAE,SAAS,CAAC,KAAG,YAIlF,CAAC;AAEF,OAAO,EAAC,SAAS,EAAC,CAAC;AACnB,
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/Utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAE,YAAY,EAAC,MAAM,wBAAwB,CAAC;AAC3E,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAuC,YAAY,EAAC,MAAM,OAAO,CAAC;AAIzE,QAAA,MAAM,YAAY,OAAQ,YAAY,YAAY,KAAK,aAAa,EAAE,SAAS,CAAC,KAAG,YAIlF,CAAC;AAEF,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,CAAC;AACnB,OAAO,EAAC,YAAY,IAAI,MAAM,EAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VitestSetup.d.ts","sourceRoot":"","sources":["../../../src/__tests__/VitestSetup.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Th.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Th.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAkC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAqB9E,UAAU,OAAO,CAAC,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAC9B;
|
|
1
|
+
{"version":3,"file":"Th.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Th.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAkC,MAAM,EAAC,MAAM,uBAAuB,CAAC;AAqB9E,UAAU,OAAO,CAAC,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;CAC9B;AAcD,eAAO,MAAM,EAAE,4CAmCd,CAAC"}
|
|
@@ -14,8 +14,8 @@ var customRender = function(ui, options) {
|
|
|
14
14
|
wrapper: TestWrapper
|
|
15
15
|
}, options));
|
|
16
16
|
};
|
|
17
|
-
export { userEvent };
|
|
18
17
|
export * from "@testing-library/react";
|
|
18
|
+
export { userEvent };
|
|
19
19
|
export { customRender as render };
|
|
20
20
|
|
|
21
21
|
//# sourceMappingURL=Utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/__tests__/Utils.tsx"],"sourcesContent":["import {render, RenderOptions, RenderResult} from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport {FunctionComponent, PropsWithChildren, ReactElement} from 'react';\n\nimport {Plasmantine} from '../theme';\n\nconst customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult => {\n const TestWrapper: FunctionComponent<PropsWithChildren> = ({children}) => <Plasmantine>{children}</Plasmantine>;\n\n return render(ui, {wrapper: TestWrapper, ...options});\n};\n\nexport
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/Utils.tsx"],"sourcesContent":["import {render, RenderOptions, RenderResult} from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport {FunctionComponent, PropsWithChildren, ReactElement} from 'react';\n\nimport {Plasmantine} from '../theme';\n\nconst customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult => {\n const TestWrapper: FunctionComponent<PropsWithChildren> = ({children}) => <Plasmantine>{children}</Plasmantine>;\n\n return render(ui, {wrapper: TestWrapper, ...options});\n};\n\nexport * from '@testing-library/react';\nexport {userEvent};\nexport {customRender as render};\n"],"names":["render","userEvent","Plasmantine","customRender","ui","options","TestWrapper","children","wrapper"],"mappings":";;AAAA,SAAQA,MAAM,QAAoC,yBAAyB;AAC3E,OAAOC,eAAe,8BAA8B;AAGpD,SAAQC,WAAW,QAAO,WAAW;AAErC,IAAMC,eAAe,SAACC,IAAkBC,SAA2D;IAC/F,IAAMC,cAAoD;YAAEC,iBAAAA;6BAAc,KAACL;sBAAaK;;;IAExF,OAAOP,OAAOI,IAAI;QAACI,SAASF;OAAgBD;AAChD;AAEA,cAAc,yBAAyB;AACvC,SAAQJ,SAAS,GAAE;AACnB,SAAQE,gBAAgBH,MAAM,GAAE"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import matchers from "@testing-library/jest-dom/matchers";
|
|
2
|
+
import { cleanup } from "@testing-library/react";
|
|
3
|
+
expect.extend(matchers);
|
|
4
|
+
Object.defineProperty(window, "matchMedia", {
|
|
5
|
+
writable: true,
|
|
6
|
+
value: vi.fn().mockImplementation(function(query) {
|
|
7
|
+
return {
|
|
8
|
+
matches: false,
|
|
9
|
+
media: query,
|
|
10
|
+
onchange: null,
|
|
11
|
+
addListener: vi.fn(),
|
|
12
|
+
removeListener: vi.fn(),
|
|
13
|
+
addEventListener: vi.fn(),
|
|
14
|
+
removeEventListener: vi.fn(),
|
|
15
|
+
dispatchEvent: vi.fn()
|
|
16
|
+
};
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
window.ResizeObserver = window.ResizeObserver || vi.fn().mockImplementation(function() {
|
|
20
|
+
return {
|
|
21
|
+
disconnect: vi.fn(),
|
|
22
|
+
observe: vi.fn(),
|
|
23
|
+
unobserve: vi.fn()
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
afterEach(function() {
|
|
27
|
+
cleanup();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=VitestSetup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/__tests__/VitestSetup.ts"],"sourcesContent":["import matchers from '@testing-library/jest-dom/matchers';\nimport {cleanup} from '@testing-library/react';\nexpect.extend(matchers);\nObject.defineProperty(window, 'matchMedia', {\n writable: true,\n value: vi.fn().mockImplementation((query) => ({\n matches: false,\n media: query,\n onchange: null,\n addListener: vi.fn(), // deprecated\n removeListener: vi.fn(), // deprecated\n addEventListener: vi.fn(),\n removeEventListener: vi.fn(),\n dispatchEvent: vi.fn(),\n })),\n});\nwindow.ResizeObserver =\n window.ResizeObserver ||\n vi.fn().mockImplementation(() => ({\n disconnect: vi.fn(),\n observe: vi.fn(),\n unobserve: vi.fn(),\n }));\n\nafterEach(() => {\n cleanup();\n});\n"],"names":["matchers","cleanup","expect","extend","Object","defineProperty","window","writable","value","vi","fn","mockImplementation","query","matches","media","onchange","addListener","removeListener","addEventListener","removeEventListener","dispatchEvent","ResizeObserver","disconnect","observe","unobserve","afterEach"],"mappings":"AAAA,OAAOA,cAAc,qCAAqC;AAC1D,SAAQC,OAAO,QAAO,yBAAyB;AAC/CC,OAAOC,MAAM,CAACH;AACdI,OAAOC,cAAc,CAACC,QAAQ,cAAc;IACxCC,UAAU,IAAI;IACdC,OAAOC,GAAGC,EAAE,GAAGC,kBAAkB,CAAC,SAACC;eAAW;YAC1CC,SAAS,KAAK;YACdC,OAAOF;YACPG,UAAU,IAAI;YACdC,aAAaP,GAAGC,EAAE;YAClBO,gBAAgBR,GAAGC,EAAE;YACrBQ,kBAAkBT,GAAGC,EAAE;YACvBS,qBAAqBV,GAAGC,EAAE;YAC1BU,eAAeX,GAAGC,EAAE;QACxB;;AACJ;AACAJ,OAAOe,cAAc,GACjBf,OAAOe,cAAc,IACrBZ,GAAGC,EAAE,GAAGC,kBAAkB,CAAC;WAAO;QAC9BW,YAAYb,GAAGC,EAAE;QACjBa,SAASd,GAAGC,EAAE;QACdc,WAAWf,GAAGC,EAAE;IACpB;;AAEJe,UAAU,WAAM;IACZxB;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { ArrowDownSize16Px, ArrowUpSize16Px, DoubleArrowHeadVSize16Px } from "@coveord/plasma-react-icons";
|
|
3
3
|
import { Center, createStyles, Group, Text, UnstyledButton } from "@mantine/core";
|
|
4
4
|
import { defaultColumnSizing, flexRender } from "@tanstack/react-table";
|
|
5
5
|
var useStyles = createStyles(function(theme) {
|
|
@@ -21,12 +21,14 @@ var useStyles = createStyles(function(theme) {
|
|
|
21
21
|
};
|
|
22
22
|
});
|
|
23
23
|
var SortingIcons = {
|
|
24
|
-
asc:
|
|
25
|
-
desc:
|
|
24
|
+
asc: ArrowUpSize16Px,
|
|
25
|
+
desc: ArrowDownSize16Px,
|
|
26
|
+
none: DoubleArrowHeadVSize16Px
|
|
26
27
|
};
|
|
27
28
|
var SortingLabels = {
|
|
28
29
|
asc: "ascending",
|
|
29
|
-
desc: "descending"
|
|
30
|
+
desc: "descending",
|
|
31
|
+
none: "none"
|
|
30
32
|
};
|
|
31
33
|
export var Th = function(param) {
|
|
32
34
|
var header = param.header;
|
|
@@ -51,14 +53,14 @@ export var Th = function(param) {
|
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
var onSort = header.column.getToggleSortingHandler();
|
|
54
|
-
var sortingOrder = header.column.getIsSorted();
|
|
55
|
-
var Icon = SortingIcons[sortingOrder
|
|
56
|
+
var sortingOrder = header.column.getIsSorted() || "none";
|
|
57
|
+
var Icon = SortingIcons[sortingOrder];
|
|
56
58
|
return /*#__PURE__*/ _jsx("th", {
|
|
57
59
|
className: classes.th,
|
|
58
60
|
style: {
|
|
59
61
|
width: width
|
|
60
62
|
},
|
|
61
|
-
"aria-sort":
|
|
63
|
+
"aria-sort": SortingLabels[sortingOrder],
|
|
62
64
|
children: /*#__PURE__*/ _jsx(UnstyledButton, {
|
|
63
65
|
onClick: onSort,
|
|
64
66
|
className: classes.control,
|
|
@@ -71,11 +73,6 @@ export var Th = function(param) {
|
|
|
71
73
|
children: flexRender(header.column.columnDef.header, header.getContext())
|
|
72
74
|
}),
|
|
73
75
|
/*#__PURE__*/ _jsx(Center, {
|
|
74
|
-
sx: function(theme) {
|
|
75
|
-
return {
|
|
76
|
-
color: sortingOrder ? theme.colors.action[8] : undefined
|
|
77
|
-
};
|
|
78
|
-
},
|
|
79
76
|
children: /*#__PURE__*/ _jsx(Icon, {
|
|
80
77
|
height: 14
|
|
81
78
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/table/Th.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/Th.tsx"],"sourcesContent":["import {ArrowDownSize16Px, ArrowUpSize16Px, DoubleArrowHeadVSize16Px} from '@coveord/plasma-react-icons';\nimport {Center, createStyles, Group, Text, UnstyledButton} from '@mantine/core';\nimport {defaultColumnSizing, flexRender, Header} from '@tanstack/react-table';\n\nconst useStyles = createStyles((theme) => ({\n th: {\n fontWeight: '400 !important' as any,\n padding: '0 !important',\n color: theme.black + '!important',\n verticalAlign: 'middle',\n },\n\n control: {\n width: '100%',\n padding: `${theme.spacing.xs}px ${theme.spacing.sm}px`,\n whiteSpace: 'nowrap',\n\n '&:hover': {\n backgroundColor: theme.colorScheme === 'dark' ? theme.colors.gray[6] : theme.colors.gray[2],\n },\n },\n}));\n\ninterface ThProps<T> {\n header: Header<T, unknown>;\n}\n\nconst SortingIcons = {\n asc: ArrowUpSize16Px,\n desc: ArrowDownSize16Px,\n none: DoubleArrowHeadVSize16Px,\n};\n\nconst SortingLabels = {\n asc: 'ascending',\n desc: 'descending',\n none: 'none',\n} as const;\n\nexport const Th = <T,>({header}: ThProps<T>) => {\n const {classes} = useStyles();\n const size = header.column.getSize();\n const width = size !== defaultColumnSizing.size ? size : undefined;\n\n if (header.isPlaceholder) {\n return null;\n }\n\n if (!header.column.getCanSort()) {\n return (\n <th className={classes.th} style={{width}}>\n <Text size=\"xs\" py=\"xs\" px=\"sm\">\n {flexRender(header.column.columnDef.header, header.getContext())}\n </Text>\n </th>\n );\n }\n\n const onSort = header.column.getToggleSortingHandler();\n const sortingOrder = header.column.getIsSorted() || 'none';\n const Icon = SortingIcons[sortingOrder];\n\n return (\n <th className={classes.th} style={{width}} aria-sort={SortingLabels[sortingOrder]}>\n <UnstyledButton onClick={onSort} className={classes.control}>\n <Group position=\"apart\" noWrap>\n <Text size=\"xs\">{flexRender(header.column.columnDef.header, header.getContext())}</Text>\n <Center>\n <Icon height={14} />\n </Center>\n </Group>\n </UnstyledButton>\n </th>\n );\n};\n"],"names":["ArrowDownSize16Px","ArrowUpSize16Px","DoubleArrowHeadVSize16Px","Center","createStyles","Group","Text","UnstyledButton","defaultColumnSizing","flexRender","useStyles","theme","th","fontWeight","padding","color","black","verticalAlign","control","width","spacing","xs","sm","whiteSpace","backgroundColor","colorScheme","colors","gray","SortingIcons","asc","desc","none","SortingLabels","Th","header","classes","size","column","getSize","undefined","isPlaceholder","getCanSort","className","style","py","px","columnDef","getContext","onSort","getToggleSortingHandler","sortingOrder","getIsSorted","Icon","aria-sort","onClick","position","noWrap","height"],"mappings":";AAAA,SAAQA,iBAAiB,EAAEC,eAAe,EAAEC,wBAAwB,QAAO,8BAA8B;AACzG,SAAQC,MAAM,EAAEC,YAAY,EAAEC,KAAK,EAAEC,IAAI,EAAEC,cAAc,QAAO,gBAAgB;AAChF,SAAQC,mBAAmB,EAAEC,UAAU,QAAe,wBAAwB;AAE9E,IAAMC,YAAYN,aAAa,SAACO;WAAW;QACvCC,IAAI;YACAC,YAAY;YACZC,SAAS;YACTC,OAAOJ,MAAMK,KAAK,GAAG;YACrBC,eAAe;QACnB;QAEAC,SAAS;YACLC,OAAO;YACPL,SAAS,AAAC,GAAwBH,OAAtBA,MAAMS,OAAO,CAACC,EAAE,EAAC,OAAsB,OAAjBV,MAAMS,OAAO,CAACE,EAAE,EAAC;YACnDC,YAAY;YAEZ,WAAW;gBACPC,iBAAiBb,MAAMc,WAAW,KAAK,SAASd,MAAMe,MAAM,CAACC,IAAI,CAAC,EAAE,GAAGhB,MAAMe,MAAM,CAACC,IAAI,CAAC,EAAE;YAC/F;QACJ;IACJ;;AAMA,IAAMC,eAAe;IACjBC,KAAK5B;IACL6B,MAAM9B;IACN+B,MAAM7B;AACV;AAEA,IAAM8B,gBAAgB;IAClBH,KAAK;IACLC,MAAM;IACNC,MAAM;AACV;AAEA,OAAO,IAAME,KAAK,gBAA8B;QAAxBC,eAAAA;IACpB,IAAM,AAACC,UAAWzB,YAAXyB;IACP,IAAMC,OAAOF,OAAOG,MAAM,CAACC,OAAO;IAClC,IAAMnB,QAAQiB,SAAS5B,oBAAoB4B,IAAI,GAAGA,OAAOG,SAAS;IAElE,IAAIL,OAAOM,aAAa,EAAE;QACtB,OAAO,IAAI;IACf,CAAC;IAED,IAAI,CAACN,OAAOG,MAAM,CAACI,UAAU,IAAI;QAC7B,qBACI,KAAC7B;YAAG8B,WAAWP,QAAQvB,EAAE;YAAE+B,OAAO;gBAACxB,OAAAA;YAAK;sBACpC,cAAA,KAACb;gBAAK8B,MAAK;gBAAKQ,IAAG;gBAAKC,IAAG;0BACtBpC,WAAWyB,OAAOG,MAAM,CAACS,SAAS,CAACZ,MAAM,EAAEA,OAAOa,UAAU;;;IAI7E,CAAC;IAED,IAAMC,SAASd,OAAOG,MAAM,CAACY,uBAAuB;IACpD,IAAMC,eAAehB,OAAOG,MAAM,CAACc,WAAW,MAAM;IACpD,IAAMC,OAAOxB,YAAY,CAACsB,aAAa;IAEvC,qBACI,KAACtC;QAAG8B,WAAWP,QAAQvB,EAAE;QAAE+B,OAAO;YAACxB,OAAAA;QAAK;QAAGkC,aAAWrB,aAAa,CAACkB,aAAa;kBAC7E,cAAA,KAAC3C;YAAe+C,SAASN;YAAQN,WAAWP,QAAQjB,OAAO;sBACvD,cAAA,MAACb;gBAAMkD,UAAS;gBAAQC,MAAM;;kCAC1B,KAAClD;wBAAK8B,MAAK;kCAAM3B,WAAWyB,OAAOG,MAAM,CAACS,SAAS,CAACZ,MAAM,EAAEA,OAAOa,UAAU;;kCAC7E,KAAC5C;kCACG,cAAA,KAACiD;4BAAKK,QAAQ;;;;;;;AAMtC,EAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coveord/plasma-mantine",
|
|
3
|
-
"version": "49.2.
|
|
3
|
+
"version": "49.2.4",
|
|
4
4
|
"description": "A Plasma flavoured Mantine theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plasma",
|
|
@@ -49,8 +49,9 @@
|
|
|
49
49
|
"@types/testing-library__jest-dom": "5.14.5",
|
|
50
50
|
"csstype": "3.1.1",
|
|
51
51
|
"embla-carousel-react": "7.0.4",
|
|
52
|
-
"eslint-plugin-jest": "27.1.1",
|
|
53
52
|
"eslint-plugin-testing-library": "5.7.2",
|
|
53
|
+
"eslint-plugin-vitest": "0.0.32",
|
|
54
|
+
"eslint-plugin-vitest-globals": "1.2.0",
|
|
54
55
|
"identity-obj-proxy": "3.0.0",
|
|
55
56
|
"jest": "29.2.1",
|
|
56
57
|
"jest-environment-jsdom": "29.1.2",
|
|
@@ -60,7 +61,8 @@
|
|
|
60
61
|
"react-dom": "18.2.0",
|
|
61
62
|
"rimraf": "3.0.2",
|
|
62
63
|
"tslib": "2.4.0",
|
|
63
|
-
"typescript": "4.9.3"
|
|
64
|
+
"typescript": "4.9.3",
|
|
65
|
+
"vitest": "0.28.3"
|
|
64
66
|
},
|
|
65
67
|
"peerDependencies": {
|
|
66
68
|
"@emotion/react": "^11.10.0",
|
|
@@ -78,8 +80,7 @@
|
|
|
78
80
|
"build": "node ../../scripts/build",
|
|
79
81
|
"clean": "rimraf dist",
|
|
80
82
|
"start": "node ../../scripts/start",
|
|
81
|
-
"test": "
|
|
82
|
-
"test:watch": "
|
|
83
|
-
"test:debug": "node --inspect-brk node_modules/jest/bin/jest --runInBand --watchAll --detectOpenHandles --forceExit"
|
|
83
|
+
"test": "TZ=UTC vitest run",
|
|
84
|
+
"test:watch": "TZ=UTC vitest"
|
|
84
85
|
}
|
|
85
86
|
}
|
package/src/__tests__/Utils.tsx
CHANGED
|
@@ -10,6 +10,6 @@ const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>
|
|
|
10
10
|
return render(ui, {wrapper: TestWrapper, ...options});
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
export {userEvent};
|
|
14
13
|
export * from '@testing-library/react';
|
|
14
|
+
export {userEvent};
|
|
15
15
|
export {customRender as render};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import matchers from '@testing-library/jest-dom/matchers';
|
|
2
|
+
import {cleanup} from '@testing-library/react';
|
|
3
|
+
expect.extend(matchers);
|
|
4
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
5
|
+
writable: true,
|
|
6
|
+
value: vi.fn().mockImplementation((query) => ({
|
|
7
|
+
matches: false,
|
|
8
|
+
media: query,
|
|
9
|
+
onchange: null,
|
|
10
|
+
addListener: vi.fn(), // deprecated
|
|
11
|
+
removeListener: vi.fn(), // deprecated
|
|
12
|
+
addEventListener: vi.fn(),
|
|
13
|
+
removeEventListener: vi.fn(),
|
|
14
|
+
dispatchEvent: vi.fn(),
|
|
15
|
+
})),
|
|
16
|
+
});
|
|
17
|
+
window.ResizeObserver =
|
|
18
|
+
window.ResizeObserver ||
|
|
19
|
+
vi.fn().mockImplementation(() => ({
|
|
20
|
+
disconnect: vi.fn(),
|
|
21
|
+
observe: vi.fn(),
|
|
22
|
+
unobserve: vi.fn(),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
afterEach(() => {
|
|
26
|
+
cleanup();
|
|
27
|
+
});
|
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import {useForm} from '@mantine/form';
|
|
2
1
|
import {loader} from '@monaco-editor/react';
|
|
3
2
|
import {render, screen, waitForElementToBeRemoved, within} from '@test-utils';
|
|
3
|
+
import {useForm} from '../../../form';
|
|
4
4
|
|
|
5
5
|
import {CodeEditor} from '../CodeEditor';
|
|
6
6
|
import {XML} from '../languages/xml';
|
|
7
7
|
|
|
8
|
+
vi.mock('monaco-editor');
|
|
9
|
+
vi.mock('@monaco-editor/react');
|
|
10
|
+
|
|
8
11
|
describe('CodeEditor', () => {
|
|
9
12
|
beforeEach(() => {
|
|
10
|
-
|
|
13
|
+
vi.clearAllMocks();
|
|
11
14
|
});
|
|
12
15
|
|
|
13
16
|
it('renders the monaco editor and a copy to clipboard button', async () => {
|
|
14
|
-
jest.mock('monaco-editor');
|
|
15
17
|
render(<CodeEditor label="label" description="description" />);
|
|
16
18
|
|
|
17
19
|
await waitForElementToBeRemoved(screen.queryByRole('presentation'));
|
|
18
20
|
|
|
19
21
|
expect(screen.getByText(/label/)).toBeInTheDocument();
|
|
20
22
|
expect(screen.getByText(/description/)).toBeInTheDocument();
|
|
21
|
-
expect(screen.
|
|
23
|
+
expect(await screen.findByTestId('monaco-editor')).toBeInTheDocument();
|
|
22
24
|
expect(await screen.findByRole('button', {name: /copy/i})).toBeInTheDocument();
|
|
23
25
|
});
|
|
24
26
|
|
|
@@ -56,7 +58,7 @@ describe('CodeEditor', () => {
|
|
|
56
58
|
});
|
|
57
59
|
|
|
58
60
|
it('loads the xml language in the monaco instance if the editor language is xml', async () => {
|
|
59
|
-
const xmlLanguageSpy =
|
|
61
|
+
const xmlLanguageSpy = vi.spyOn(XML, 'register').mockImplementation(vi.fn());
|
|
60
62
|
render(<CodeEditor label="label" description="description" monacoLoader="cdn" language="xml" />);
|
|
61
63
|
expect(xmlLanguageSpy).toHaveBeenCalledTimes(1);
|
|
62
64
|
});
|
|
@@ -54,7 +54,7 @@ describe('Collection', () => {
|
|
|
54
54
|
|
|
55
55
|
it('calls the onRemoveItem function when clicking on a remove button', async () => {
|
|
56
56
|
const user = userEvent.setup({delay: null});
|
|
57
|
-
const onRemoveItemSpy =
|
|
57
|
+
const onRemoveItemSpy = vi.fn();
|
|
58
58
|
const Fixture = () => {
|
|
59
59
|
const form = useForm({initialValues: {fruits: ['banana', 'orange']}});
|
|
60
60
|
return (
|
|
@@ -128,7 +128,7 @@ describe('Collection', () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it('disables the add button whenever allowAdd callback returns false', () => {
|
|
131
|
-
const allowAdd =
|
|
131
|
+
const allowAdd = vi.fn().mockImplementation(() => false);
|
|
132
132
|
const Fixture = () => {
|
|
133
133
|
const form = useForm({initialValues: {fruits: ['banana', 'orange']}});
|
|
134
134
|
return (
|
|
@@ -6,8 +6,8 @@ import {DateRangePickerInlineCalendar} from '../DateRangePickerInlineCalendar';
|
|
|
6
6
|
describe('DateRangePickerInlineCalendar', () => {
|
|
7
7
|
it('calls onApply when the user clicks on the apply button', async () => {
|
|
8
8
|
const user = userEvent.setup({delay: null});
|
|
9
|
-
const onApply =
|
|
10
|
-
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={
|
|
9
|
+
const onApply = vi.fn();
|
|
10
|
+
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={vi.fn()} />);
|
|
11
11
|
|
|
12
12
|
await user.click(screen.getByRole('button', {name: 'Apply'}));
|
|
13
13
|
|
|
@@ -17,8 +17,8 @@ describe('DateRangePickerInlineCalendar', () => {
|
|
|
17
17
|
|
|
18
18
|
it('calls onCancel when the user clicks on the cancel button', async () => {
|
|
19
19
|
const user = userEvent.setup({delay: null});
|
|
20
|
-
const onCancel =
|
|
21
|
-
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={
|
|
20
|
+
const onCancel = vi.fn();
|
|
21
|
+
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={vi.fn()} onCancel={onCancel} />);
|
|
22
22
|
|
|
23
23
|
await user.click(screen.getByRole('button', {name: 'Cancel'}));
|
|
24
24
|
|
|
@@ -26,14 +26,14 @@ describe('DateRangePickerInlineCalendar', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('does not render the preset searchbox when there is no presets', () => {
|
|
29
|
-
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={
|
|
29
|
+
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={vi.fn()} onCancel={vi.fn()} />);
|
|
30
30
|
|
|
31
31
|
expect(screen.queryByRole('searchbox')).not.toBeInTheDocument();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('calls onApply with the selected dates when choosing a preset', async () => {
|
|
35
35
|
const user = userEvent.setup({delay: null});
|
|
36
|
-
const onApply =
|
|
36
|
+
const onApply = vi.fn();
|
|
37
37
|
render(
|
|
38
38
|
<DateRangePickerInlineCalendar
|
|
39
39
|
presets={{
|
|
@@ -41,7 +41,7 @@ describe('DateRangePickerInlineCalendar', () => {
|
|
|
41
41
|
}}
|
|
42
42
|
initialRange={[null, null]}
|
|
43
43
|
onApply={onApply}
|
|
44
|
-
onCancel={
|
|
44
|
+
onCancel={vi.fn()}
|
|
45
45
|
/>
|
|
46
46
|
);
|
|
47
47
|
|
|
@@ -58,9 +58,9 @@ describe('DateRangePickerInlineCalendar', () => {
|
|
|
58
58
|
|
|
59
59
|
it('calls onApply with the selected dates when clicking in the calendar', async () => {
|
|
60
60
|
const user = userEvent.setup({delay: null});
|
|
61
|
-
|
|
62
|
-
const onApply =
|
|
63
|
-
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={
|
|
61
|
+
vi.useFakeTimers().setSystemTime(new Date(2022, 0, 31));
|
|
62
|
+
const onApply = vi.fn();
|
|
63
|
+
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={vi.fn()} />);
|
|
64
64
|
|
|
65
65
|
// click once for the start, once for the end
|
|
66
66
|
await user.click(screen.getAllByRole('button', {name: '8'})[0]);
|
|
@@ -70,27 +70,27 @@ describe('DateRangePickerInlineCalendar', () => {
|
|
|
70
70
|
|
|
71
71
|
expect(onApply).toHaveBeenCalledWith([new Date(2022, 0, 8), new Date(2022, 0, 14)]);
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
vi.useRealTimers();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it('set end date same as start date if only one date is selected when clicking in the calendar', async () => {
|
|
77
77
|
const user = userEvent.setup({delay: null});
|
|
78
|
-
|
|
79
|
-
const onApply =
|
|
80
|
-
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={
|
|
78
|
+
vi.useFakeTimers().setSystemTime(new Date(2022, 0, 31));
|
|
79
|
+
const onApply = vi.fn();
|
|
80
|
+
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={vi.fn()} />);
|
|
81
81
|
|
|
82
82
|
await user.click(screen.getAllByRole('button', {name: '8'})[0]);
|
|
83
83
|
await user.click(screen.getByRole('button', {name: 'Apply'}));
|
|
84
84
|
|
|
85
85
|
expect(onApply).toHaveBeenCalledWith([new Date(2022, 0, 8), new Date(2022, 0, 8)]);
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
vi.useRealTimers();
|
|
88
88
|
});
|
|
89
89
|
|
|
90
90
|
it('calls onApply with the selected dates when typing in the inputs', async () => {
|
|
91
91
|
const user = userEvent.setup({delay: null});
|
|
92
|
-
const onApply =
|
|
93
|
-
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={
|
|
92
|
+
const onApply = vi.fn();
|
|
93
|
+
render(<DateRangePickerInlineCalendar initialRange={[null, null]} onApply={onApply} onCancel={vi.fn()} />);
|
|
94
94
|
|
|
95
95
|
const startInput = screen.getByRole('textbox', {
|
|
96
96
|
name: /start/i,
|
|
@@ -7,10 +7,13 @@ import {DateRangePickerPopoverCalendar} from '../DateRangePickerPopoverCalendar'
|
|
|
7
7
|
// Since we're mocking the date and the animations are timer based we're mocking useReduceMotion to disable all the animations
|
|
8
8
|
// I tried wrapping the components in <MantineProvider theme={{components: {Transition: {defaultProps: {duration: 0}}}}}>
|
|
9
9
|
// but the animation was still happening. :(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
vi.mock('@mantine/hooks', async () => {
|
|
11
|
+
const actual = await vi.importActual('@mantine/hooks');
|
|
12
|
+
return {
|
|
13
|
+
...actual,
|
|
14
|
+
useReduceMotion: () => true,
|
|
15
|
+
};
|
|
16
|
+
});
|
|
14
17
|
|
|
15
18
|
describe('DateRangePickerPopoverCalendar', () => {
|
|
16
19
|
it('does not render the preset searchbox when there is no presets', () => {
|
|
@@ -49,7 +52,7 @@ describe('DateRangePickerPopoverCalendar', () => {
|
|
|
49
52
|
|
|
50
53
|
it('calls onApply with the selected dates when clicking in the calendar', async () => {
|
|
51
54
|
const user = userEvent.setup({delay: null});
|
|
52
|
-
|
|
55
|
+
vi.useFakeTimers().setSystemTime(new Date(2022, 0, 31));
|
|
53
56
|
const Fixture = () => {
|
|
54
57
|
const form = useForm<{dates: DateRangePickerValue}>({initialValues: {dates: [null, null]}});
|
|
55
58
|
return (
|
|
@@ -67,11 +70,12 @@ describe('DateRangePickerPopoverCalendar', () => {
|
|
|
67
70
|
await user.click(screen.getAllByRole('button', {name: '14'})[0]);
|
|
68
71
|
|
|
69
72
|
// hides the calendar when the second date is clicked
|
|
70
|
-
expect(screen.
|
|
73
|
+
expect(screen.queryAllByRole('button', {name: '8'})[0]).not.toBeVisible();
|
|
74
|
+
expect(screen.queryAllByRole('button', {name: '8'})[1]).not.toBeVisible();
|
|
71
75
|
|
|
72
76
|
expect(screen.getByTestId('json')).toHaveTextContent('["2022-01-08T00:00:00.000Z","2022-01-14T00:00:00.000Z"]');
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
vi.useRealTimers();
|
|
75
79
|
});
|
|
76
80
|
|
|
77
81
|
it('calls onApply with the selected dates when typing in the inputs', async () => {
|
|
@@ -5,7 +5,7 @@ import {DateRangePickerPresetSelect} from '../DateRangePickerPresetSelect';
|
|
|
5
5
|
describe('DateRangePickerPresetSelect', () => {
|
|
6
6
|
it('calls onChange when selecting a preset', async () => {
|
|
7
7
|
const user = userEvent.setup({delay: null});
|
|
8
|
-
const onChange =
|
|
8
|
+
const onChange = vi.fn();
|
|
9
9
|
render(
|
|
10
10
|
<DateRangePickerPresetSelect
|
|
11
11
|
value={[null, null]}
|