@axinom/mosaic-ui 0.69.0-rc.13 → 0.69.0-rc.16
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/helpers/testing.d.ts +2 -1
- package/dist/helpers/testing.d.ts.map +1 -1
- package/package.json +10 -9
- package/src/components/Accordion/Accordion.spec.tsx +1 -1
- package/src/components/Accordion/AccordionItem/AccordionItem.spec.tsx +2 -2
- package/src/components/Actions/Action/Action.spec.tsx +24 -23
- package/src/components/Actions/Actions.spec.tsx +10 -8
- package/src/components/Buttons/Button/Button.spec.tsx +4 -3
- package/src/components/Buttons/CompositeButton/CompositeButton.spec.tsx +4 -3
- package/src/components/Buttons/TextButton/TextButton.spec.tsx +4 -3
- package/src/components/ConfirmDialog/ConfirmDialog.spec.tsx +5 -4
- package/src/components/DateTime/DatePicker/DatePicker.spec.tsx +1 -0
- package/src/components/DateTime/DateTimePicker.spec.tsx +3 -2
- package/src/components/DateTime/TimePicker/ScrollColumn/ScrollColumn.spec.tsx +3 -2
- package/src/components/DateTime/TimePicker/TimePicker.spec.tsx +3 -2
- package/src/components/DynamicDataList/DynamicDataList.spec.tsx +26 -24
- package/src/components/DynamicDataList/DynamicListDataEntry/DynamicListDataEntry.spec.tsx +10 -9
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createInputRenderer/createInputRenderer.spec.tsx +3 -2
- package/src/components/DynamicDataList/DynamicListDataEntry/Renderers/createSelectRenderer/createSelectRenderer.spec.tsx +3 -2
- package/src/components/DynamicDataList/DynamicListHeader/DynamicListHeader.spec.tsx +9 -8
- package/src/components/DynamicDataList/DynamicListRow/DynamicListRow.spec.tsx +4 -3
- package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.actions.spec.ts +1 -0
- package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.init.spec.ts +1 -0
- package/src/components/DynamicDataList/helpers/DynamicListReducer/DynamicListReducer.spec.ts +6 -5
- package/src/components/EmptyStation/EmptyStation.spec.tsx +4 -5
- package/src/components/Explorer/BulkEdit/FormFieldsConfigConverter.spec.tsx +24 -23
- package/src/components/Explorer/BulkEdit/GenerateMutation.spec.tsx +1 -0
- package/src/components/Explorer/Explorer.spec.tsx +57 -57
- package/src/components/Explorer/NavigationExplorer/NavigationExplorer.spec.tsx +11 -12
- package/src/components/Explorer/QuickEdit/useQuickEdit.spec.tsx +12 -11
- package/src/components/Explorer/SelectionExplorer/SelectionExplorer.spec.tsx +10 -11
- package/src/components/Explorer/helpers/InMemoryDataProvider.spec.ts +1 -0
- package/src/components/Explorer/helpers/useFilters.spec.tsx +13 -11
- package/src/components/Explorer/helpers/useStationMessage.spec.tsx +4 -3
- package/src/components/Explorer/helpers/useSubtitle.spec.tsx +1 -0
- package/src/components/FieldSelection/FieldSelection.spec.tsx +1 -1
- package/src/components/Filters/Filter/Filter.spec.tsx +4 -3
- package/src/components/Filters/Filters.spec.tsx +3 -2
- package/src/components/Filters/SelectionTypes/DateTimeFilter/DateTimeFilter.spec.tsx +11 -10
- package/src/components/Filters/SelectionTypes/FreeTextFilter/FreeTextFilter.spec.tsx +6 -5
- package/src/components/Filters/SelectionTypes/NumericTextFilter/NumericTextFilter.spec.tsx +5 -4
- package/src/components/Filters/SelectionTypes/OptionsFilter/OptionsFilter.spec.tsx +2 -1
- package/src/components/Filters/Validators/DateRangeFilterValidator.spec.ts +1 -0
- package/src/components/Filters/Validators/NumberRangeFilterValidator.spec.ts +1 -0
- package/src/components/FormElements/BooleanView/BooleanViewField.spec.tsx +1 -0
- package/src/components/FormElements/Checkbox/Checkbox.spec.tsx +9 -8
- package/src/components/FormElements/CustomTags/CustomTags.spec.tsx +48 -47
- package/src/components/FormElements/DateTimeField/DateTimeText.spec.tsx +11 -10
- package/src/components/FormElements/DynamicDataListControl/DynamicDataListControl.spec.tsx +5 -4
- package/src/components/FormElements/FileUploadControl/FileUploadControl.spec.tsx +10 -9
- package/src/components/FormElements/FormElementContainer/FormElementContainer.spec.tsx +1 -0
- package/src/components/FormElements/Link/LinkField.spec.tsx +1 -0
- package/src/components/FormElements/MaskedSingleLineText/MaskedSingleLineText.spec.tsx +1 -0
- package/src/components/FormElements/Radio/Radio.spec.tsx +10 -9
- package/src/components/FormElements/ReadOnly/ReadOnlyField.spec.tsx +2 -1
- package/src/components/FormElements/ReadOnlyText/ReadOnlyTextField.spec.tsx +2 -1
- package/src/components/FormElements/Select/Select.spec.tsx +4 -3
- package/src/components/FormElements/SingleLineText/SingleLineText.spec.tsx +6 -5
- package/src/components/FormElements/Tags/Tags.spec.tsx +5 -4
- package/src/components/FormElements/TextArea/TextArea.spec.tsx +5 -4
- package/src/components/FormElements/ToggleButton/ToggleButton.spec.tsx +9 -8
- package/src/components/FormStation/FormStation.spec.tsx +27 -27
- package/src/components/FormStation/SaveOnNavigate/SaveOnNavigate.spec.tsx +12 -11
- package/src/components/FormStation/SaveOnNavigate/handleNavigationAttempt.spec.ts +25 -24
- package/src/components/FormStation/helpers/useTitle.spec.ts +9 -7
- package/src/components/Hub/Hub.spec.tsx +1 -0
- package/src/components/Hub/Tile/Tile.spec.tsx +1 -0
- package/src/components/Icons/Icons.spec.tsx +1 -0
- package/src/components/InfoPanel/InfoImage/InfoImage.spec.tsx +1 -0
- package/src/components/InfoPanel/InfoPanel.spec.tsx +1 -0
- package/src/components/InfoPanel/Paragraph/Paragraph.spec.tsx +1 -0
- package/src/components/InfoPanel/Section/Section.spec.tsx +1 -0
- package/src/components/InlineMenu/InlineMenu.spec.tsx +1 -0
- package/src/components/LandingPageHeader/LandingPageHeader.spec.tsx +1 -0
- package/src/components/LandingPageTiles/LandingPageTiles.spec.tsx +1 -0
- package/src/components/LandingPageTiles/TileLarge/TileLarge.spec.tsx +1 -0
- package/src/components/LandingPageTiles/TileSmall/TileSmall.spec.tsx +1 -0
- package/src/components/List/List.spec.tsx +17 -16
- package/src/components/List/ListCheckBox/ListCheckBox.spec.tsx +6 -5
- package/src/components/List/ListHeader/ColumnLabel/ColumnLabel.spec.tsx +5 -4
- package/src/components/List/ListHeader/ListHeader.spec.tsx +9 -8
- package/src/components/List/ListRow/ListRow.spec.tsx +12 -11
- package/src/components/List/ListRow/ListRowCell/ListRowCell.spec.tsx +1 -0
- package/src/components/List/ListRow/ListRowLoader.spec.tsx +1 -0
- package/src/components/List/ListRow/Renderers/BooleanDotRenderer/BooleanDotRenderer.spec.tsx +1 -0
- package/src/components/List/ListRow/Renderers/ExternalLinkRenderer/ExternalLinkRenderer.spec.tsx +2 -1
- package/src/components/List/ListRow/Renderers/StateRenderer/StateRenderer.spec.tsx +1 -0
- package/src/components/List/ListRow/Renderers/TagsRenderer/TagsRenderer.spec.tsx +18 -17
- package/src/components/List/ListRowRenderer/ListRowRenderer.spec.tsx +31 -30
- package/src/components/Loaders/ImageLoader/ImageLoader.spec.tsx +4 -3
- package/src/components/Loaders/Loader/Loader.spec.tsx +6 -4
- package/src/components/Message/Message.spec.tsx +1 -0
- package/src/components/MessageBar/MessageBar.spec.tsx +3 -2
- package/src/components/Modal/Modal.spec.tsx +5 -4
- package/src/components/NavigationAwareStation/NavigationAwareStation.spec.tsx +17 -16
- package/src/components/PageHeader/PageHeader.spec.tsx +2 -1
- package/src/components/PageHeader/PageHeaderAction/PageHeaderAction.spec.tsx +22 -21
- package/src/components/PageHeader/PageHeaderActionsGroup/PageHeaderActionsGroup.spec.tsx +4 -3
- package/src/components/ProgressBar/ProgressBar.spec.tsx +1 -0
- package/src/components/Utils/Postgraphile/CreateConnectionRenderer.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/FilterTransformer.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/RangeTransformer.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/SortTransformer.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/UpdateGQLFragmentGenerator.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/generateArrayMutations.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/getArrayDiff.spec.ts +1 -0
- package/src/components/Utils/Postgraphile/getFormDiff.spec.ts +1 -0
- package/src/components/Utils/State/GlobalState.spec.ts +4 -2
- package/src/components/Utils/Transformers/Boolean.spec.ts +1 -0
- package/src/components/Utils/Transformers/DateTime.spec.ts +2 -1
- package/src/components/Utils/Transformers/FileSize.spec.ts +1 -0
- package/src/components/Utils/Transformers/SortArray.spec.ts +1 -0
- package/src/components/Utils/Transformers/Timestamp.spec.ts +3 -2
- package/src/components/Utils/Transformers/TitleCase.spec.ts +1 -0
- package/src/components/VisualElements/ImgElement.spec.tsx +1 -0
- package/src/components/VisualElements/SvgElement.spec.tsx +1 -0
- package/src/helpers/testing.ts +3 -4
- package/src/hooks/useBusy/useBusy.spec.tsx +3 -2
- package/src/hooks/useClickOutside/useClickOutside.spec.tsx +1 -1
- package/src/hooks/useDebounce/useDebounce.spec.tsx +4 -3
- package/src/hooks/useExpand/useExpand.spec.tsx +1 -0
- package/src/hooks/useTabTitle/useTabTitle.spec.tsx +11 -11
- package/src/hooks/useValueOrOnDemand/useValueOrOnDemand.spec.tsx +2 -1
- package/src/utils/ErrorMapper/ApolloClient/ApolloErrorMapper.spec.ts +1 -0
- package/src/utils/ErrorMapper/ErrorMapper.spec.ts +1 -0
- package/src/utils/ErrorTypeToStationError.spec.tsx +1 -0
- package/src/utils/ToolTipHelpers.spec.ts +1 -0
- package/src/validators/timestamp/timestamp.spec.ts +1 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MockInstance } from 'vitest';
|
|
1
2
|
/**
|
|
2
3
|
* Helper method to that calls the given function inside an `act` function
|
|
3
4
|
* and returns the return of that function.
|
|
@@ -21,5 +22,5 @@ export declare function actWithReturn<T>(render: () => T | Promise<T>): Promise<
|
|
|
21
22
|
* This helper will not mock any thing. It's just converting Typescript types!
|
|
22
23
|
* @param f the mocked function
|
|
23
24
|
*/
|
|
24
|
-
export declare const asSpy: <T>(fn: (...args: any) => T) =>
|
|
25
|
+
export declare const asSpy: <T>(fn: (...args: any) => T) => MockInstance;
|
|
25
26
|
//# sourceMappingURL=testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/helpers/testing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/helpers/testing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,aAAa,CAAC,CAAC,EACnC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,CAAC,CAQZ;AAED;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,EAAE,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC,KAAG,YAElD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axinom/mosaic-ui",
|
|
3
|
-
"version": "0.69.0-rc.
|
|
3
|
+
"version": "0.69.0-rc.16",
|
|
4
4
|
"description": "UI components for building Axinom Mosaic applications",
|
|
5
5
|
"author": "Axinom",
|
|
6
6
|
"license": "PROPRIETARY",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"build": "yarn clean && cross-env NODE_ENV=production rollup -c",
|
|
23
23
|
"build:ci": "yarn workspaces focus && yarn build",
|
|
24
24
|
"dev": "rollup -c -w",
|
|
25
|
-
"test": "
|
|
26
|
-
"test:watch": "
|
|
27
|
-
"test:coverage": "
|
|
28
|
-
"test:ci": "
|
|
25
|
+
"test": "vitest run --silent",
|
|
26
|
+
"test:watch": "vitest watch",
|
|
27
|
+
"test:coverage": "vitest run --coverage",
|
|
28
|
+
"test:ci": "vitest run --reporter=default --reporter=junit --coverage --coverage.reporter=cobertura --coverage.reporter=html",
|
|
29
29
|
"prettier": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}\" --loglevel silent",
|
|
30
30
|
"lint": "eslint . --ext .ts,.tsx,.js --color --cache",
|
|
31
31
|
"storybook": "storybook dev -p 6006",
|
|
32
32
|
"build-storybook": "storybook build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@axinom/mosaic-core": "^0.4.31-rc.
|
|
35
|
+
"@axinom/mosaic-core": "^0.4.31-rc.8",
|
|
36
36
|
"@faker-js/faker": "^7.4.0",
|
|
37
37
|
"@geoffcox/react-splitter": "^2.1.2",
|
|
38
38
|
"@mui/base": "5.0.0-beta.40",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"cross-env": "^7.0.3",
|
|
90
90
|
"css-loader": "^6.5.1",
|
|
91
91
|
"formik": "^2.1.4",
|
|
92
|
-
"
|
|
92
|
+
"jsdom": "^25.0.0",
|
|
93
93
|
"prettier": "^2.8.8",
|
|
94
94
|
"react": "^17.0.2",
|
|
95
95
|
"react-dom": "^17.0.2",
|
|
@@ -107,10 +107,11 @@
|
|
|
107
107
|
"storybook": "^7.0.6",
|
|
108
108
|
"style-loader": "^3.3.1",
|
|
109
109
|
"typescript": "^5.9.3",
|
|
110
|
-
"typescript-plugin-css-modules": "^5.0.2"
|
|
110
|
+
"typescript-plugin-css-modules": "^5.0.2",
|
|
111
|
+
"vitest": "^4.0.18"
|
|
111
112
|
},
|
|
112
113
|
"publishConfig": {
|
|
113
114
|
"access": "public"
|
|
114
115
|
},
|
|
115
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "61cc0e626bb816beee81d16b31c46f1d2a13844d"
|
|
116
117
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
2
1
|
import { configure, fireEvent, render, screen } from '@testing-library/react';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { describe, expect, it } from 'vitest';
|
|
4
4
|
import { Accordion } from './Accordion';
|
|
5
5
|
import { AccordionItem } from './AccordionItem/AccordionItem';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
2
1
|
import { configure, fireEvent, render, screen } from '@testing-library/react';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
4
|
import { AccordionItem } from './AccordionItem';
|
|
5
5
|
|
|
6
6
|
configure({ testIdAttribute: 'data-test-id' });
|
|
@@ -16,7 +16,7 @@ describe('AccordionItem', () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
it('calls toggleExpanded when row is clicked', () => {
|
|
19
|
-
const toggleExpanded =
|
|
19
|
+
const toggleExpanded = vi.fn();
|
|
20
20
|
render(
|
|
21
21
|
<AccordionItem header={header} toggleExpanded={toggleExpanded}>
|
|
22
22
|
{content}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from '@testing-library/react';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
10
|
+
import { afterEach, describe, expect, it, test, vi } from 'vitest';
|
|
10
11
|
import { noop } from '../../../helpers/utils';
|
|
11
12
|
import { ConfirmationConfig } from '../../ConfirmDialog';
|
|
12
13
|
import { IconName } from '../../Icons';
|
|
@@ -188,7 +189,7 @@ describe('Action', () => {
|
|
|
188
189
|
});
|
|
189
190
|
|
|
190
191
|
it('raises the onActionSelected event', () => {
|
|
191
|
-
const spy =
|
|
192
|
+
const spy = vi.fn();
|
|
192
193
|
const { getByTestId } = render(
|
|
193
194
|
<Action
|
|
194
195
|
{...defaultContextProps}
|
|
@@ -225,7 +226,7 @@ describe('Action', () => {
|
|
|
225
226
|
const mockLabel = 'test-label';
|
|
226
227
|
|
|
227
228
|
it(`'Simple' mode changes the background color when clicked for the first time`, () => {
|
|
228
|
-
const spy =
|
|
229
|
+
const spy = vi.fn();
|
|
229
230
|
|
|
230
231
|
const { getByTestId } = render(
|
|
231
232
|
<Action
|
|
@@ -248,7 +249,7 @@ describe('Action', () => {
|
|
|
248
249
|
|
|
249
250
|
it(`'Simple' mode renders a confirmation message, raises the onActionSelected event after confirmation, and resets the action label`, () => {
|
|
250
251
|
const confirmationMsg = 'Click again to confirm';
|
|
251
|
-
const spy =
|
|
252
|
+
const spy = vi.fn();
|
|
252
253
|
|
|
253
254
|
const { getByTestId } = render(
|
|
254
255
|
<Action
|
|
@@ -281,8 +282,8 @@ describe('Action', () => {
|
|
|
281
282
|
|
|
282
283
|
it(`'Simple' mode renders a confirmation message, and doesn't raise the 'onActionSelected' event on 'mouseleave' when confirmation is required`, async () => {
|
|
283
284
|
const confirmationMsg = 'Click again to confirm';
|
|
284
|
-
const spy =
|
|
285
|
-
|
|
285
|
+
const spy = vi.fn();
|
|
286
|
+
vi.useFakeTimers();
|
|
286
287
|
|
|
287
288
|
const { getByTestId } = render(
|
|
288
289
|
<Action
|
|
@@ -309,7 +310,7 @@ describe('Action', () => {
|
|
|
309
310
|
|
|
310
311
|
fireEvent.mouseLeave(action);
|
|
311
312
|
|
|
312
|
-
|
|
313
|
+
vi.runAllTimers();
|
|
313
314
|
|
|
314
315
|
await waitFor(() => {
|
|
315
316
|
label = getByTestId('label');
|
|
@@ -319,11 +320,11 @@ describe('Action', () => {
|
|
|
319
320
|
expect(spy).not.toHaveBeenCalled();
|
|
320
321
|
expect(action.classList.contains('hasConfirm')).toBe(false);
|
|
321
322
|
|
|
322
|
-
|
|
323
|
+
vi.useRealTimers();
|
|
323
324
|
});
|
|
324
325
|
|
|
325
326
|
it(`'Advanced' mode changes the background color when clicked for the first time`, () => {
|
|
326
|
-
const spy =
|
|
327
|
+
const spy = vi.fn();
|
|
327
328
|
|
|
328
329
|
const { getByTestId } = render(
|
|
329
330
|
<Action
|
|
@@ -345,7 +346,7 @@ describe('Action', () => {
|
|
|
345
346
|
});
|
|
346
347
|
|
|
347
348
|
it(`'Advanced' mode renders a confirmation pop up, raises the 'onActionSelected' event after the 'Confirm' button is clicked, and finally dismisses the confirmation pop up`, () => {
|
|
348
|
-
const spy =
|
|
349
|
+
const spy = vi.fn();
|
|
349
350
|
|
|
350
351
|
const { queryByText, getByText, getByTestId } = render(
|
|
351
352
|
<Action
|
|
@@ -375,7 +376,7 @@ describe('Action', () => {
|
|
|
375
376
|
});
|
|
376
377
|
|
|
377
378
|
it(`'Advanced' mode renders a confirmation pop up, does not raise the 'onActionSelected' event after the 'Cancel' button is clicked, and finally dismisses the confirmation pop up`, () => {
|
|
378
|
-
const spy =
|
|
379
|
+
const spy = vi.fn();
|
|
379
380
|
|
|
380
381
|
const { queryByText, getByText, getByTestId } = render(
|
|
381
382
|
<Action
|
|
@@ -404,8 +405,8 @@ describe('Action', () => {
|
|
|
404
405
|
});
|
|
405
406
|
|
|
406
407
|
it(`'Advanced' mode renders a confirmation pop up, does not raise the 'onActionSelected' event when the mouse leaves component, and finally dismisses the confirmation pop up`, async () => {
|
|
407
|
-
const spy =
|
|
408
|
-
|
|
408
|
+
const spy = vi.fn();
|
|
409
|
+
vi.useFakeTimers();
|
|
409
410
|
|
|
410
411
|
const { queryByText, getByText, getByTestId } = render(
|
|
411
412
|
<Action
|
|
@@ -429,7 +430,7 @@ describe('Action', () => {
|
|
|
429
430
|
|
|
430
431
|
fireEvent.mouseLeave(action);
|
|
431
432
|
|
|
432
|
-
|
|
433
|
+
vi.runAllTimers();
|
|
433
434
|
|
|
434
435
|
// TODO: Debug why this isn't passing
|
|
435
436
|
// await waitFor(() => {
|
|
@@ -438,7 +439,7 @@ describe('Action', () => {
|
|
|
438
439
|
// });
|
|
439
440
|
expect(spy).not.toHaveBeenCalled();
|
|
440
441
|
|
|
441
|
-
|
|
442
|
+
vi.useRealTimers();
|
|
442
443
|
});
|
|
443
444
|
|
|
444
445
|
it(`'Advanced' mode accepts a 'confirmationConfig' object`, () => {
|
|
@@ -474,7 +475,7 @@ describe('Action', () => {
|
|
|
474
475
|
});
|
|
475
476
|
|
|
476
477
|
it(`'Simple' raises onConfirmOpen if set`, () => {
|
|
477
|
-
const confirmToggleSpy =
|
|
478
|
+
const confirmToggleSpy = vi.fn();
|
|
478
479
|
|
|
479
480
|
const { getByTestId } = render(
|
|
480
481
|
<Action
|
|
@@ -504,9 +505,9 @@ describe('Action', () => {
|
|
|
504
505
|
});
|
|
505
506
|
|
|
506
507
|
it(`'Simple' raises onConfirmOpen when 'mouseleave' if set`, () => {
|
|
507
|
-
const confirmToggleSpy =
|
|
508
|
+
const confirmToggleSpy = vi.fn();
|
|
508
509
|
|
|
509
|
-
|
|
510
|
+
vi.useFakeTimers();
|
|
510
511
|
|
|
511
512
|
const { getByTestId } = render(
|
|
512
513
|
<Action
|
|
@@ -531,18 +532,18 @@ describe('Action', () => {
|
|
|
531
532
|
});
|
|
532
533
|
|
|
533
534
|
act(() => {
|
|
534
|
-
|
|
535
|
+
vi.runAllTimers();
|
|
535
536
|
});
|
|
536
537
|
|
|
537
538
|
expect(confirmToggleSpy).toHaveBeenCalledTimes(2);
|
|
538
539
|
expect(confirmToggleSpy).toHaveBeenNthCalledWith(1, true);
|
|
539
540
|
expect(confirmToggleSpy).toHaveBeenNthCalledWith(2, false);
|
|
540
541
|
|
|
541
|
-
|
|
542
|
+
vi.useRealTimers();
|
|
542
543
|
});
|
|
543
544
|
|
|
544
545
|
it(`'Advanced' raises onConfirmOpen when 'Cancel' is clicked, if set`, () => {
|
|
545
|
-
const confirmToggleSpy =
|
|
546
|
+
const confirmToggleSpy = vi.fn();
|
|
546
547
|
|
|
547
548
|
const { getByTestId, getByText } = render(
|
|
548
549
|
<Action
|
|
@@ -570,7 +571,7 @@ describe('Action', () => {
|
|
|
570
571
|
});
|
|
571
572
|
|
|
572
573
|
it(`'Advanced' raises onConfirmOpen when 'Confirm' is clicked, if set`, () => {
|
|
573
|
-
const confirmToggleSpy =
|
|
574
|
+
const confirmToggleSpy = vi.fn();
|
|
574
575
|
|
|
575
576
|
const { getByTestId, getByText } = render(
|
|
576
577
|
<Action
|
|
@@ -607,7 +608,7 @@ describe('isNavigationAction', () => {
|
|
|
607
608
|
});
|
|
608
609
|
|
|
609
610
|
test('returns false for a ContextActionData object', () => {
|
|
610
|
-
const action = { label: 'Context Action', onActionSelected:
|
|
611
|
+
const action = { label: 'Context Action', onActionSelected: vi.fn() };
|
|
611
612
|
expect(isNavigationAction(action)).toBe(false);
|
|
612
613
|
});
|
|
613
614
|
|
|
@@ -623,7 +624,7 @@ describe('isNavigationAction', () => {
|
|
|
623
624
|
|
|
624
625
|
describe('isContextAction', () => {
|
|
625
626
|
test('returns true for a ContextActionData object', () => {
|
|
626
|
-
const action = { label: 'Context Action', onActionSelected:
|
|
627
|
+
const action = { label: 'Context Action', onActionSelected: vi.fn() };
|
|
627
628
|
expect(isContextAction(action)).toBe(true);
|
|
628
629
|
});
|
|
629
630
|
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { fireEvent, render } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { Mock } from 'vitest';
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
3
5
|
import { useBusy } from '../../hooks/useBusy/useBusy';
|
|
4
6
|
import { IconName } from '../Icons';
|
|
5
7
|
import { Actions } from './Actions';
|
|
6
8
|
import { ActionData } from './Actions.models';
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
useBusy:
|
|
10
|
+
vi.mock('../../initialize');
|
|
11
|
+
vi.mock('../../hooks/useBusy/useBusy', () => ({
|
|
12
|
+
useBusy: vi.fn(() => ({ isBusy: false })),
|
|
11
13
|
}));
|
|
12
14
|
|
|
13
|
-
const spy1 =
|
|
14
|
-
const spy2 =
|
|
15
|
-
const spy3 =
|
|
15
|
+
const spy1 = vi.fn();
|
|
16
|
+
const spy2 = vi.fn();
|
|
17
|
+
const spy3 = vi.fn();
|
|
16
18
|
const mockActions: ActionData[] = [
|
|
17
19
|
{ label: 'action-label', onActionSelected: spy1 },
|
|
18
20
|
{ label: 'action-label', onActionSelected: spy2 },
|
|
@@ -21,7 +23,7 @@ const mockActions: ActionData[] = [
|
|
|
21
23
|
|
|
22
24
|
describe('Actions', () => {
|
|
23
25
|
beforeEach(() => {
|
|
24
|
-
|
|
26
|
+
vi.clearAllMocks();
|
|
25
27
|
});
|
|
26
28
|
|
|
27
29
|
it('renders the component without crashing', () => {
|
|
@@ -92,7 +94,7 @@ describe('Actions', () => {
|
|
|
92
94
|
});
|
|
93
95
|
|
|
94
96
|
it('disables all actions when busy', () => {
|
|
95
|
-
(useBusy as
|
|
97
|
+
(useBusy as Mock).mockImplementation(() => ({ isBusy: true }));
|
|
96
98
|
|
|
97
99
|
const { container } = render(<Actions actions={mockActions} />);
|
|
98
100
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fireEvent, render } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
import { IconName } from '../../Icons';
|
|
5
6
|
import { ButtonContext } from '../Button.model';
|
|
6
7
|
import { Button } from './Button';
|
|
@@ -26,7 +27,7 @@ describe('Button (with icon)', () => {
|
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
it('raises the onButtonClicked event', () => {
|
|
29
|
-
const spy =
|
|
30
|
+
const spy = vi.fn();
|
|
30
31
|
const { container } = render(<Button onButtonClicked={spy} />);
|
|
31
32
|
|
|
32
33
|
const button = container.querySelector('button')!;
|
|
@@ -77,7 +78,7 @@ describe('Button (with icon)', () => {
|
|
|
77
78
|
});
|
|
78
79
|
|
|
79
80
|
it('allows the button to be enabled by default', () => {
|
|
80
|
-
const spy =
|
|
81
|
+
const spy = vi.fn();
|
|
81
82
|
const { container } = render(<Button onButtonClicked={spy} />);
|
|
82
83
|
|
|
83
84
|
const button = container.querySelector('button')!;
|
|
@@ -89,7 +90,7 @@ describe('Button (with icon)', () => {
|
|
|
89
90
|
});
|
|
90
91
|
|
|
91
92
|
it('allows button to be disabled', () => {
|
|
92
|
-
const spy =
|
|
93
|
+
const spy = vi.fn();
|
|
93
94
|
const { container } = render(
|
|
94
95
|
<Button disabled={true} onButtonClicked={spy} />,
|
|
95
96
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fireEvent, render } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
import { IconName } from '../../Icons';
|
|
5
6
|
import { ButtonContext } from '../Button.model';
|
|
6
7
|
import { CompositeButton } from './CompositeButton';
|
|
@@ -22,7 +23,7 @@ describe('CompositeButton', () => {
|
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
it('raises the onButtonClicked event', () => {
|
|
25
|
-
const spy =
|
|
26
|
+
const spy = vi.fn();
|
|
26
27
|
const { container } = render(<CompositeButton onButtonClicked={spy} />);
|
|
27
28
|
|
|
28
29
|
const button = container.querySelector('button')!;
|
|
@@ -79,7 +80,7 @@ describe('CompositeButton', () => {
|
|
|
79
80
|
});
|
|
80
81
|
|
|
81
82
|
it('allows the button to be enabled by default', () => {
|
|
82
|
-
const spy =
|
|
83
|
+
const spy = vi.fn();
|
|
83
84
|
const { container } = render(<CompositeButton onButtonClicked={spy} />);
|
|
84
85
|
|
|
85
86
|
const button = container.querySelector('button')!;
|
|
@@ -91,7 +92,7 @@ describe('CompositeButton', () => {
|
|
|
91
92
|
});
|
|
92
93
|
|
|
93
94
|
it('allows button to be disabled', () => {
|
|
94
|
-
const spy =
|
|
95
|
+
const spy = vi.fn();
|
|
95
96
|
const { container } = render(
|
|
96
97
|
<CompositeButton disabled={true} onButtonClicked={spy} />,
|
|
97
98
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { fireEvent, render } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { BrowserRouter as Router } from 'react-router-dom';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
import { ButtonContext } from '../Button.model';
|
|
5
6
|
import { TextButton } from './TextButton';
|
|
6
7
|
|
|
@@ -13,7 +14,7 @@ describe('TextButton', () => {
|
|
|
13
14
|
});
|
|
14
15
|
|
|
15
16
|
it('raises the onButtonClicked event', () => {
|
|
16
|
-
const spy =
|
|
17
|
+
const spy = vi.fn();
|
|
17
18
|
const { container } = render(<TextButton onButtonClicked={spy} />);
|
|
18
19
|
|
|
19
20
|
const button = container.querySelector('button')!;
|
|
@@ -64,7 +65,7 @@ describe('TextButton', () => {
|
|
|
64
65
|
});
|
|
65
66
|
|
|
66
67
|
it('allows the button to be enabled by default', () => {
|
|
67
|
-
const spy =
|
|
68
|
+
const spy = vi.fn();
|
|
68
69
|
const { container } = render(<TextButton onButtonClicked={spy} />);
|
|
69
70
|
|
|
70
71
|
const button = container.querySelector('button')!;
|
|
@@ -76,7 +77,7 @@ describe('TextButton', () => {
|
|
|
76
77
|
});
|
|
77
78
|
|
|
78
79
|
it('allows button to be disabled', () => {
|
|
79
|
-
const spy =
|
|
80
|
+
const spy = vi.fn();
|
|
80
81
|
const { container } = render(
|
|
81
82
|
<TextButton disabled={true} onButtonClicked={spy} />,
|
|
82
83
|
);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
2
2
|
import React, { useState } from 'react';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
4
|
import { ConfirmDialog } from './ConfirmDialog';
|
|
4
5
|
import { ConfirmationConfig } from './ConfirmDialog.models';
|
|
5
6
|
|
|
@@ -45,7 +46,7 @@ describe('ConfirmDialog', () => {
|
|
|
45
46
|
});
|
|
46
47
|
|
|
47
48
|
it('disables container click event propagation', () => {
|
|
48
|
-
const parentClickSpy =
|
|
49
|
+
const parentClickSpy = vi.fn();
|
|
49
50
|
const { container } = render(
|
|
50
51
|
<div onClick={parentClickSpy}>
|
|
51
52
|
<ConfirmDialog />
|
|
@@ -128,8 +129,8 @@ describe('ConfirmDialog', () => {
|
|
|
128
129
|
});
|
|
129
130
|
|
|
130
131
|
it(`raises both 'onCancel' and 'onConfirm'`, () => {
|
|
131
|
-
const cancelSpy =
|
|
132
|
-
const confirmSpy =
|
|
132
|
+
const cancelSpy = vi.fn();
|
|
133
|
+
const confirmSpy = vi.fn();
|
|
133
134
|
|
|
134
135
|
render(<ConfirmDialog onCancel={cancelSpy} onConfirm={confirmSpy} />);
|
|
135
136
|
|
|
@@ -145,7 +146,7 @@ describe('ConfirmDialog', () => {
|
|
|
145
146
|
});
|
|
146
147
|
|
|
147
148
|
it(`raises 'onConfirmOpen' if set`, () => {
|
|
148
|
-
const spy =
|
|
149
|
+
const spy = vi.fn();
|
|
149
150
|
render(<TestWrapper onConfirmOpen={spy} />);
|
|
150
151
|
|
|
151
152
|
const mountButton = screen.getByTestId('test-mount');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { render } from '@testing-library/react';
|
|
2
2
|
import { DateTime, Settings } from 'luxon';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
import { DateTimePicker } from './DateTimePicker';
|
|
5
6
|
|
|
6
7
|
describe('DatePicker', () => {
|
|
@@ -38,7 +39,7 @@ describe('DatePicker', () => {
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
it('propagates updated values from TimePicker', () => {
|
|
41
|
-
const spy =
|
|
42
|
+
const spy = vi.fn();
|
|
42
43
|
const { container } = render(<DateTimePicker onSelected={spy} />);
|
|
43
44
|
|
|
44
45
|
// TimePicker should be present - check for scroll columns
|
|
@@ -50,7 +51,7 @@ describe('DatePicker', () => {
|
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
it('propagates updated values from DatePicker', () => {
|
|
53
|
-
const spy =
|
|
54
|
+
const spy = vi.fn();
|
|
54
55
|
const { container } = render(<DateTimePicker onSelected={spy} />);
|
|
55
56
|
|
|
56
57
|
// DatePicker should be present
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { fireEvent, render } from '@testing-library/react';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
3
4
|
import { ScrollColumn } from './ScrollColumn';
|
|
4
5
|
|
|
5
6
|
describe('ScrollColumn', () => {
|
|
@@ -40,7 +41,7 @@ describe('ScrollColumn', () => {
|
|
|
40
41
|
|
|
41
42
|
it('fires onSelected event when an item is selected', () => {
|
|
42
43
|
const itemContent = 'test';
|
|
43
|
-
const selectedSpy =
|
|
44
|
+
const selectedSpy = vi.fn();
|
|
44
45
|
const { container } = render(
|
|
45
46
|
<ScrollColumn
|
|
46
47
|
items={[itemContent]}
|
|
@@ -59,7 +60,7 @@ describe('ScrollColumn', () => {
|
|
|
59
60
|
|
|
60
61
|
it('fires onSelected event when an item is selected through the wheel', () => {
|
|
61
62
|
const itemContent = 'test';
|
|
62
|
-
const selectedSpy =
|
|
63
|
+
const selectedSpy = vi.fn();
|
|
63
64
|
const { container } = render(
|
|
64
65
|
<ScrollColumn
|
|
65
66
|
items={[itemContent]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { render } from '@testing-library/react';
|
|
2
2
|
import { DateTime, Settings } from 'luxon';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
4
5
|
import { TimePicker } from './TimePicker';
|
|
5
6
|
|
|
6
7
|
describe('DatePicker', () => {
|
|
@@ -31,7 +32,7 @@ describe('DatePicker', () => {
|
|
|
31
32
|
|
|
32
33
|
it('fires onSelected event when a value is selected', () => {
|
|
33
34
|
const now = DateTime.local();
|
|
34
|
-
const spy =
|
|
35
|
+
const spy = vi.fn();
|
|
35
36
|
const { container } = render(<TimePicker value={now} onSelected={spy} />);
|
|
36
37
|
|
|
37
38
|
// TimePicker requires complex interactions to activate columns and change values
|
|
@@ -76,7 +77,7 @@ describe('DatePicker', () => {
|
|
|
76
77
|
|
|
77
78
|
it('fires onSelected event with 24 hour format when 12 hour display time is set', () => {
|
|
78
79
|
const now = DateTime.local().set({ hour: 15 });
|
|
79
|
-
const spy =
|
|
80
|
+
const spy = vi.fn();
|
|
80
81
|
const { container } = render(
|
|
81
82
|
<TimePicker value={now} onSelected={spy} hours12={true} />,
|
|
82
83
|
);
|