@synerise/ds-mocks 0.1.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/CHANGELOG.md +10 -0
- package/LICENSE.md +21 -0
- package/README.md +426 -0
- package/dist/Button/index.d.ts +1 -0
- package/dist/Button/index.js +1 -0
- package/dist/Button/jest.d.ts +6 -0
- package/dist/Button/jest.js +37 -0
- package/dist/Button/vi.d.ts +30 -0
- package/dist/Button/vi.js +51 -0
- package/dist/Cruds/index.d.ts +1 -0
- package/dist/Cruds/index.js +1 -0
- package/dist/Cruds/jest.d.ts +6 -0
- package/dist/Cruds/jest.js +53 -0
- package/dist/Cruds/vi.d.ts +30 -0
- package/dist/Cruds/vi.js +67 -0
- package/dist/Dropdown/index.d.ts +1 -0
- package/dist/Dropdown/index.js +1 -0
- package/dist/Dropdown/jest.d.ts +6 -0
- package/dist/Dropdown/jest.js +39 -0
- package/dist/Dropdown/vi.d.ts +30 -0
- package/dist/Dropdown/vi.js +53 -0
- package/dist/Form/index.d.ts +1 -0
- package/dist/Form/index.js +1 -0
- package/dist/Form/jest.d.ts +16 -0
- package/dist/Form/jest.js +95 -0
- package/dist/Form/vi.d.ts +51 -0
- package/dist/Form/vi.js +109 -0
- package/dist/Icon/index.d.ts +1 -0
- package/dist/Icon/index.js +1 -0
- package/dist/Icon/jest.d.ts +38 -0
- package/dist/Icon/jest.js +77 -0
- package/dist/Icon/vi.d.ts +45 -0
- package/dist/Icon/vi.js +70 -0
- package/dist/Input/index.d.ts +1 -0
- package/dist/Input/index.js +1 -0
- package/dist/Input/jest.d.ts +6 -0
- package/dist/Input/jest.js +59 -0
- package/dist/Input/vi.d.ts +32 -0
- package/dist/Input/vi.js +73 -0
- package/dist/Modal/index.d.ts +1 -0
- package/dist/Modal/index.js +1 -0
- package/dist/Modal/jest.d.ts +6 -0
- package/dist/Modal/jest.js +67 -0
- package/dist/Modal/vi.d.ts +30 -0
- package/dist/Modal/vi.js +81 -0
- package/dist/Select/index.d.ts +1 -0
- package/dist/Select/index.js +1 -0
- package/dist/Select/jest.d.ts +6 -0
- package/dist/Select/jest.js +68 -0
- package/dist/Select/vi.d.ts +35 -0
- package/dist/Select/vi.js +82 -0
- package/dist/Table/index.d.ts +1 -0
- package/dist/Table/index.js +1 -0
- package/dist/Table/jest.d.ts +6 -0
- package/dist/Table/jest.js +111 -0
- package/dist/Table/vi.d.ts +30 -0
- package/dist/Table/vi.js +126 -0
- package/dist/Tabs/index.d.ts +1 -0
- package/dist/Tabs/index.js +1 -0
- package/dist/Tabs/jest.d.ts +7 -0
- package/dist/Tabs/jest.js +46 -0
- package/dist/Tabs/vi.d.ts +31 -0
- package/dist/Tabs/vi.js +60 -0
- package/dist/Tooltip/index.d.ts +1 -0
- package/dist/Tooltip/index.js +1 -0
- package/dist/Tooltip/jest.d.ts +8 -0
- package/dist/Tooltip/jest.js +40 -0
- package/dist/Tooltip/vi.d.ts +32 -0
- package/dist/Tooltip/vi.js +56 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -0
- package/dist/jest.d.ts +11 -0
- package/dist/jest.js +11 -0
- package/package.json +157 -0
package/dist/Cruds/vi.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Cruds mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { crudsMockFactory } from '@synerise/ds-mocks/Cruds/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-cruds', crudsMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var crudsMockFactory = function crudsMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var onAdd = _ref.onAdd,
|
|
17
|
+
onEdit = _ref.onEdit,
|
|
18
|
+
onDelete = _ref.onDelete,
|
|
19
|
+
onRemove = _ref.onRemove,
|
|
20
|
+
onDuplicate = _ref.onDuplicate,
|
|
21
|
+
onMoveUp = _ref.onMoveUp,
|
|
22
|
+
onMoveDown = _ref.onMoveDown,
|
|
23
|
+
dataTestId = _ref['data-testid'];
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
"data-testid": dataTestId || 'ds-cruds',
|
|
26
|
+
className: "ds-cruds"
|
|
27
|
+
}, onAdd && /*#__PURE__*/React.createElement("button", {
|
|
28
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-add",
|
|
29
|
+
onClick: onAdd
|
|
30
|
+
}, "Add"), onEdit && /*#__PURE__*/React.createElement("button", {
|
|
31
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-edit",
|
|
32
|
+
onClick: onEdit
|
|
33
|
+
}, "Edit"), onDuplicate && /*#__PURE__*/React.createElement("button", {
|
|
34
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-duplicate",
|
|
35
|
+
onClick: onDuplicate
|
|
36
|
+
}, "Duplicate"), onDelete && /*#__PURE__*/React.createElement("button", {
|
|
37
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-delete",
|
|
38
|
+
onClick: onDelete
|
|
39
|
+
}, "Delete"), onRemove && /*#__PURE__*/React.createElement("button", {
|
|
40
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-remove",
|
|
41
|
+
onClick: onRemove
|
|
42
|
+
}, "Remove"), onMoveUp && /*#__PURE__*/React.createElement("button", {
|
|
43
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-move-up",
|
|
44
|
+
onClick: onMoveUp
|
|
45
|
+
}, "Up"), onMoveDown && /*#__PURE__*/React.createElement("button", {
|
|
46
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-move-down",
|
|
47
|
+
onClick: onMoveDown
|
|
48
|
+
}, "Down"));
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Factory function for minimal Cruds mock.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* vi.mock('@synerise/ds-cruds', crudsMinimalMockFactory);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export var crudsMinimalMockFactory = function crudsMinimalMockFactory() {
|
|
62
|
+
return {
|
|
63
|
+
"default": vi.fn(function () {
|
|
64
|
+
return null;
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockDropdown = function mockDropdown() {
|
|
3
|
+
jest.mock('@synerise/ds-dropdown', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
overlay = _ref.overlay,
|
|
9
|
+
open = _ref.open,
|
|
10
|
+
onOpenChange = _ref.onOpenChange,
|
|
11
|
+
disabled = _ref.disabled,
|
|
12
|
+
dataTestId = _ref['data-testid'];
|
|
13
|
+
var testId = dataTestId || 'ds-dropdown';
|
|
14
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
15
|
+
"data-testid": testId,
|
|
16
|
+
className: "ds-dropdown"
|
|
17
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
"data-testid": testId + "-trigger",
|
|
19
|
+
onClick: function onClick() {
|
|
20
|
+
return !disabled && (onOpenChange == null ? void 0 : onOpenChange(!open));
|
|
21
|
+
}
|
|
22
|
+
}, children), open && /*#__PURE__*/React.createElement("div", {
|
|
23
|
+
"data-testid": testId + "-overlay"
|
|
24
|
+
}, overlay));
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export var mockDropdownMinimal = function mockDropdownMinimal() {
|
|
30
|
+
jest.mock('@synerise/ds-dropdown', function () {
|
|
31
|
+
return {
|
|
32
|
+
__esModule: true,
|
|
33
|
+
"default": jest.fn(function (_ref2) {
|
|
34
|
+
var children = _ref2.children;
|
|
35
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DropdownProps } from '@synerise/ds-dropdown';
|
|
3
|
+
export type MockDropdownProps = DropdownProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Dropdown mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { dropdownMockFactory } from '@synerise/ds-mocks/Dropdown/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-dropdown', dropdownMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const dropdownMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ children, overlay, open, onOpenChange, disabled, "data-testid": dataTestId, }: MockDropdownProps) => React.JSX.Element>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Factory function for minimal Dropdown mock.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* vi.mock('@synerise/ds-dropdown', dropdownMinimalMockFactory);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const dropdownMinimalMockFactory: () => {
|
|
29
|
+
default: import("vitest").Mock<({ children }: MockDropdownProps) => React.JSX.Element>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Dropdown mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { dropdownMockFactory } from '@synerise/ds-mocks/Dropdown/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-dropdown', dropdownMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var dropdownMockFactory = function dropdownMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var children = _ref.children,
|
|
17
|
+
overlay = _ref.overlay,
|
|
18
|
+
open = _ref.open,
|
|
19
|
+
onOpenChange = _ref.onOpenChange,
|
|
20
|
+
disabled = _ref.disabled,
|
|
21
|
+
dataTestId = _ref['data-testid'];
|
|
22
|
+
var testId = dataTestId || 'ds-dropdown';
|
|
23
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
"data-testid": testId,
|
|
25
|
+
className: "ds-dropdown"
|
|
26
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
27
|
+
"data-testid": testId + "-trigger",
|
|
28
|
+
onClick: function onClick() {
|
|
29
|
+
return !disabled && (onOpenChange == null ? void 0 : onOpenChange(!open));
|
|
30
|
+
}
|
|
31
|
+
}, children), open && /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
"data-testid": testId + "-overlay"
|
|
33
|
+
}, overlay));
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Factory function for minimal Dropdown mock.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* vi.mock('@synerise/ds-dropdown', dropdownMinimalMockFactory);
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export var dropdownMinimalMockFactory = function dropdownMinimalMockFactory() {
|
|
47
|
+
return {
|
|
48
|
+
"default": vi.fn(function (_ref2) {
|
|
49
|
+
var children = _ref2.children;
|
|
50
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
51
|
+
})
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { EditListProps, EditableParam } from '@synerise/ds-form';
|
|
3
|
+
export type { EditableParam };
|
|
4
|
+
export type MockEditableListProps = EditListProps & {
|
|
5
|
+
'data-testid'?: string;
|
|
6
|
+
};
|
|
7
|
+
export type MockFieldSetProps = {
|
|
8
|
+
className?: string;
|
|
9
|
+
heading: ReactNode;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
withLine?: boolean;
|
|
13
|
+
'data-testid'?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const mockForm: () => void;
|
|
16
|
+
export declare const mockFormMinimal: () => void;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockForm = function mockForm() {
|
|
3
|
+
jest.mock('@synerise/ds-form', function () {
|
|
4
|
+
var FieldSet = jest.fn(function (_ref) {
|
|
5
|
+
var heading = _ref.heading,
|
|
6
|
+
description = _ref.description,
|
|
7
|
+
children = _ref.children,
|
|
8
|
+
withLine = _ref.withLine,
|
|
9
|
+
dataTestId = _ref['data-testid'];
|
|
10
|
+
var testId = dataTestId || 'ds-fieldset';
|
|
11
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
"data-testid": testId,
|
|
13
|
+
className: "ds-fieldset",
|
|
14
|
+
"data-with-line": withLine
|
|
15
|
+
}, heading && /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
"data-testid": testId + "-heading"
|
|
17
|
+
}, heading), description && /*#__PURE__*/React.createElement("div", {
|
|
18
|
+
"data-testid": testId + "-description"
|
|
19
|
+
}, description), children);
|
|
20
|
+
});
|
|
21
|
+
var Form = Object.assign(jest.fn(function () {
|
|
22
|
+
return null;
|
|
23
|
+
}), {
|
|
24
|
+
FieldSet: FieldSet
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
__esModule: true,
|
|
28
|
+
"default": Form,
|
|
29
|
+
EditableList: jest.fn(function (_ref2) {
|
|
30
|
+
var _ref2$value = _ref2.value,
|
|
31
|
+
value = _ref2$value === void 0 ? [] : _ref2$value,
|
|
32
|
+
onClickDelete = _ref2.onClickDelete,
|
|
33
|
+
leftColumnName = _ref2.leftColumnName,
|
|
34
|
+
rightColumnName = _ref2.rightColumnName,
|
|
35
|
+
addButtonConfig = _ref2.addButtonConfig,
|
|
36
|
+
renderLeftColumn = _ref2.renderLeftColumn,
|
|
37
|
+
renderRightColumn = _ref2.renderRightColumn,
|
|
38
|
+
renderActions = _ref2.renderActions,
|
|
39
|
+
dataTestId = _ref2['data-testid'];
|
|
40
|
+
var testId = dataTestId || 'ds-editable-list';
|
|
41
|
+
var renderRowActions = function renderRowActions(param, index, params) {
|
|
42
|
+
if (typeof renderActions === 'function') {
|
|
43
|
+
return renderActions(param, index, params, {
|
|
44
|
+
onClickDelete: onClickDelete
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (renderActions === false) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
51
|
+
"data-testid": testId + "-delete-" + index,
|
|
52
|
+
onClick: function onClick() {
|
|
53
|
+
return onClickDelete == null ? void 0 : onClickDelete(param, index);
|
|
54
|
+
}
|
|
55
|
+
}, "Delete");
|
|
56
|
+
};
|
|
57
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
"data-testid": testId,
|
|
59
|
+
className: "ds-editable-list"
|
|
60
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
"data-testid": testId + "-header"
|
|
62
|
+
}, leftColumnName && /*#__PURE__*/React.createElement("span", null, leftColumnName), rightColumnName && /*#__PURE__*/React.createElement("span", null, rightColumnName)), /*#__PURE__*/React.createElement("div", {
|
|
63
|
+
"data-testid": testId + "-rows"
|
|
64
|
+
}, value.map(function (param, index) {
|
|
65
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
key: index,
|
|
67
|
+
"data-testid": testId + "-row-" + index
|
|
68
|
+
}, renderLeftColumn ? renderLeftColumn(param, index) : /*#__PURE__*/React.createElement("span", null, param.name), renderRightColumn ? renderRightColumn(param, index) : /*#__PURE__*/React.createElement("span", null, param.value), renderRowActions(param, index, value));
|
|
69
|
+
})), addButtonConfig && /*#__PURE__*/React.createElement("button", {
|
|
70
|
+
"data-testid": testId + "-add",
|
|
71
|
+
onClick: addButtonConfig.onClickAddRow,
|
|
72
|
+
disabled: addButtonConfig.disableAddButton
|
|
73
|
+
}, addButtonConfig.textAddButton || 'Add'));
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export var mockFormMinimal = function mockFormMinimal() {
|
|
79
|
+
jest.mock('@synerise/ds-form', function () {
|
|
80
|
+
var Form = Object.assign(jest.fn(function () {
|
|
81
|
+
return null;
|
|
82
|
+
}), {
|
|
83
|
+
FieldSet: jest.fn(function () {
|
|
84
|
+
return null;
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
return {
|
|
88
|
+
__esModule: true,
|
|
89
|
+
"default": Form,
|
|
90
|
+
EditableList: jest.fn(function () {
|
|
91
|
+
return null;
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { EditListProps, EditableParam } from '@synerise/ds-form';
|
|
3
|
+
export type { EditableParam };
|
|
4
|
+
export type MockEditableListProps = EditListProps & {
|
|
5
|
+
'data-testid'?: string;
|
|
6
|
+
};
|
|
7
|
+
export type MockFieldSetProps = {
|
|
8
|
+
className?: string;
|
|
9
|
+
heading: ReactNode;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
withLine?: boolean;
|
|
13
|
+
'data-testid'?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Factory function for Form mock.
|
|
17
|
+
* Mocks the entire @synerise/ds-form package including Form, Form.FieldSet, and EditableList.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { formMockFactory } from '@synerise/ds-mocks/Form/vi';
|
|
22
|
+
*
|
|
23
|
+
* vi.mock('@synerise/ds-form', formMockFactory);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const formMockFactory: () => {
|
|
27
|
+
default: import("vitest").MockInstance<() => null> & {
|
|
28
|
+
(): null;
|
|
29
|
+
new (): null;
|
|
30
|
+
} & {} & {
|
|
31
|
+
FieldSet: import("vitest").Mock<({ heading, description, children, withLine, "data-testid": dataTestId, }: MockFieldSetProps) => React.JSX.Element>;
|
|
32
|
+
};
|
|
33
|
+
EditableList: import("vitest").Mock<({ value, onClickDelete, leftColumnName, rightColumnName, addButtonConfig, renderLeftColumn, renderRightColumn, renderActions, "data-testid": dataTestId, }: MockEditableListProps) => React.JSX.Element>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Factory function for minimal Form mock.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* vi.mock('@synerise/ds-form', formMinimalMockFactory);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const formMinimalMockFactory: () => {
|
|
44
|
+
default: import("vitest").MockInstance<() => null> & {
|
|
45
|
+
(): null;
|
|
46
|
+
new (): null;
|
|
47
|
+
} & {} & {
|
|
48
|
+
FieldSet: import("vitest").Mock<() => null>;
|
|
49
|
+
};
|
|
50
|
+
EditableList: import("vitest").Mock<() => null>;
|
|
51
|
+
};
|
package/dist/Form/vi.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Form mock.
|
|
4
|
+
* Mocks the entire @synerise/ds-form package including Form, Form.FieldSet, and EditableList.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { formMockFactory } from '@synerise/ds-mocks/Form/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-form', formMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var formMockFactory = function formMockFactory() {
|
|
14
|
+
var FieldSet = vi.fn(function (_ref) {
|
|
15
|
+
var heading = _ref.heading,
|
|
16
|
+
description = _ref.description,
|
|
17
|
+
children = _ref.children,
|
|
18
|
+
withLine = _ref.withLine,
|
|
19
|
+
dataTestId = _ref['data-testid'];
|
|
20
|
+
var testId = dataTestId || 'ds-fieldset';
|
|
21
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
"data-testid": testId,
|
|
23
|
+
className: "ds-fieldset",
|
|
24
|
+
"data-with-line": withLine
|
|
25
|
+
}, heading && /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
"data-testid": testId + "-heading"
|
|
27
|
+
}, heading), description && /*#__PURE__*/React.createElement("div", {
|
|
28
|
+
"data-testid": testId + "-description"
|
|
29
|
+
}, description), children);
|
|
30
|
+
});
|
|
31
|
+
var Form = Object.assign(vi.fn(function () {
|
|
32
|
+
return null;
|
|
33
|
+
}), {
|
|
34
|
+
FieldSet: FieldSet
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
"default": Form,
|
|
38
|
+
EditableList: vi.fn(function (_ref2) {
|
|
39
|
+
var _ref2$value = _ref2.value,
|
|
40
|
+
value = _ref2$value === void 0 ? [] : _ref2$value,
|
|
41
|
+
onClickDelete = _ref2.onClickDelete,
|
|
42
|
+
leftColumnName = _ref2.leftColumnName,
|
|
43
|
+
rightColumnName = _ref2.rightColumnName,
|
|
44
|
+
addButtonConfig = _ref2.addButtonConfig,
|
|
45
|
+
renderLeftColumn = _ref2.renderLeftColumn,
|
|
46
|
+
renderRightColumn = _ref2.renderRightColumn,
|
|
47
|
+
renderActions = _ref2.renderActions,
|
|
48
|
+
dataTestId = _ref2['data-testid'];
|
|
49
|
+
var testId = dataTestId || 'ds-editable-list';
|
|
50
|
+
var renderRowActions = function renderRowActions(param, index, params) {
|
|
51
|
+
if (typeof renderActions === 'function') {
|
|
52
|
+
return renderActions(param, index, params, {
|
|
53
|
+
onClickDelete: onClickDelete
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (renderActions === false) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
60
|
+
"data-testid": testId + "-delete-" + index,
|
|
61
|
+
onClick: function onClick() {
|
|
62
|
+
return onClickDelete == null ? void 0 : onClickDelete(param, index);
|
|
63
|
+
}
|
|
64
|
+
}, "Delete");
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
67
|
+
"data-testid": testId,
|
|
68
|
+
className: "ds-editable-list"
|
|
69
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
"data-testid": testId + "-header"
|
|
71
|
+
}, leftColumnName && /*#__PURE__*/React.createElement("span", null, leftColumnName), rightColumnName && /*#__PURE__*/React.createElement("span", null, rightColumnName)), /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
"data-testid": testId + "-rows"
|
|
73
|
+
}, value.map(function (param, index) {
|
|
74
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
75
|
+
key: index,
|
|
76
|
+
"data-testid": testId + "-row-" + index
|
|
77
|
+
}, renderLeftColumn ? renderLeftColumn(param, index) : /*#__PURE__*/React.createElement("span", null, param.name), renderRightColumn ? renderRightColumn(param, index) : /*#__PURE__*/React.createElement("span", null, param.value), renderRowActions(param, index, value));
|
|
78
|
+
})), addButtonConfig && /*#__PURE__*/React.createElement("button", {
|
|
79
|
+
"data-testid": testId + "-add",
|
|
80
|
+
onClick: addButtonConfig.onClickAddRow,
|
|
81
|
+
disabled: addButtonConfig.disableAddButton
|
|
82
|
+
}, addButtonConfig.textAddButton || 'Add'));
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Factory function for minimal Form mock.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* vi.mock('@synerise/ds-form', formMinimalMockFactory);
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export var formMinimalMockFactory = function formMinimalMockFactory() {
|
|
96
|
+
var Form = Object.assign(vi.fn(function () {
|
|
97
|
+
return null;
|
|
98
|
+
}), {
|
|
99
|
+
FieldSet: vi.fn(function () {
|
|
100
|
+
return null;
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
"default": Form,
|
|
105
|
+
EditableList: vi.fn(function () {
|
|
106
|
+
return null;
|
|
107
|
+
})
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { IconProps } from '@synerise/ds-icon';
|
|
2
|
+
export type MockIconProps = IconProps & {
|
|
3
|
+
'data-testid'?: string;
|
|
4
|
+
/** Icon name as string */
|
|
5
|
+
iconName?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Mocks the main Icon component from @synerise/ds-icon.
|
|
9
|
+
* The mock renders the `iconName` prop as text content.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* // In your test file:
|
|
14
|
+
* import { mockIcon } from '@synerise/ds-mocks/Icon/jest';
|
|
15
|
+
*
|
|
16
|
+
* mockIcon();
|
|
17
|
+
*
|
|
18
|
+
* // Then in your component:
|
|
19
|
+
* <Icon iconName="InfoM" /> // Renders as: <div data-icon="InfoM">InfoM</div>
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const mockIcon: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Mocks the Icon component with a custom render function.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* mockIconWithRender((props) => (
|
|
29
|
+
* <span data-custom-icon={props.iconName}>{props.iconName}</span>
|
|
30
|
+
* ));
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare const mockIconWithRender: (renderFn: (props: IconProps) => JSX.Element) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Mocks the Icon component to render nothing (null).
|
|
36
|
+
* Useful when you don't need to test icon rendering.
|
|
37
|
+
*/
|
|
38
|
+
export declare const mockIconMinimal: () => void;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Mocks the main Icon component from @synerise/ds-icon.
|
|
4
|
+
* The mock renders the `iconName` prop as text content.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* // In your test file:
|
|
9
|
+
* import { mockIcon } from '@synerise/ds-mocks/Icon/jest';
|
|
10
|
+
*
|
|
11
|
+
* mockIcon();
|
|
12
|
+
*
|
|
13
|
+
* // Then in your component:
|
|
14
|
+
* <Icon iconName="InfoM" /> // Renders as: <div data-icon="InfoM">InfoM</div>
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export var mockIcon = function mockIcon() {
|
|
18
|
+
jest.mock('@synerise/ds-icon', function () {
|
|
19
|
+
return {
|
|
20
|
+
__esModule: true,
|
|
21
|
+
"default": jest.fn(function (_ref) {
|
|
22
|
+
var name = _ref.name,
|
|
23
|
+
iconName = _ref.iconName,
|
|
24
|
+
component = _ref.component,
|
|
25
|
+
className = _ref.className,
|
|
26
|
+
size = _ref.size,
|
|
27
|
+
color = _ref.color,
|
|
28
|
+
stroke = _ref.stroke,
|
|
29
|
+
dataTestId = _ref['data-testid'];
|
|
30
|
+
var resolvedIconName = iconName || name;
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: "ds-icon " + (className || ''),
|
|
33
|
+
"data-testid": dataTestId || 'ds-icon',
|
|
34
|
+
"data-icon": resolvedIconName,
|
|
35
|
+
"data-icon-size": size,
|
|
36
|
+
"data-icon-color": color,
|
|
37
|
+
"data-icon-stroke": stroke,
|
|
38
|
+
title: resolvedIconName
|
|
39
|
+
}, component || resolvedIconName || 'Icon');
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Mocks the Icon component with a custom render function.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* mockIconWithRender((props) => (
|
|
51
|
+
* <span data-custom-icon={props.iconName}>{props.iconName}</span>
|
|
52
|
+
* ));
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export var mockIconWithRender = function mockIconWithRender(renderFn) {
|
|
56
|
+
jest.mock('@synerise/ds-icon', function () {
|
|
57
|
+
return {
|
|
58
|
+
__esModule: true,
|
|
59
|
+
"default": jest.fn(renderFn)
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Mocks the Icon component to render nothing (null).
|
|
66
|
+
* Useful when you don't need to test icon rendering.
|
|
67
|
+
*/
|
|
68
|
+
export var mockIconMinimal = function mockIconMinimal() {
|
|
69
|
+
jest.mock('@synerise/ds-icon', function () {
|
|
70
|
+
return {
|
|
71
|
+
__esModule: true,
|
|
72
|
+
"default": jest.fn(function () {
|
|
73
|
+
return null;
|
|
74
|
+
})
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IconProps } from '@synerise/ds-icon';
|
|
3
|
+
export type MockIconProps = IconProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
/** Icon name as string */
|
|
6
|
+
iconName?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Factory function for Icon mock.
|
|
10
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { iconMockFactory } from '@synerise/ds-mocks/Icon/vi';
|
|
15
|
+
*
|
|
16
|
+
* vi.mock('@synerise/ds-icon', iconMockFactory);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const iconMockFactory: () => {
|
|
20
|
+
default: import("vitest").Mock<({ name, iconName, component, className, size, color, stroke, "data-testid": dataTestId, }: MockIconProps) => React.JSX.Element>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Factory function for Icon mock with custom render function.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* vi.mock('@synerise/ds-icon', iconWithRenderMockFactory((props) => (
|
|
28
|
+
* <span data-custom-icon={props.iconName}>{props.iconName}</span>
|
|
29
|
+
* )));
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const iconWithRenderMockFactory: (renderFn: (props: IconProps) => JSX.Element) => () => {
|
|
33
|
+
default: import("vitest").Mock<(props: IconProps) => JSX.Element>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Factory function for minimal Icon mock.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* vi.mock('@synerise/ds-icon', iconMinimalMockFactory);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare const iconMinimalMockFactory: () => {
|
|
44
|
+
default: import("vitest").Mock<() => null>;
|
|
45
|
+
};
|