@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/Icon/vi.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Icon mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { iconMockFactory } from '@synerise/ds-mocks/Icon/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-icon', iconMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var iconMockFactory = function iconMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var name = _ref.name,
|
|
17
|
+
iconName = _ref.iconName,
|
|
18
|
+
component = _ref.component,
|
|
19
|
+
className = _ref.className,
|
|
20
|
+
size = _ref.size,
|
|
21
|
+
color = _ref.color,
|
|
22
|
+
stroke = _ref.stroke,
|
|
23
|
+
dataTestId = _ref['data-testid'];
|
|
24
|
+
var resolvedIconName = iconName || name;
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
className: "ds-icon " + (className || ''),
|
|
27
|
+
"data-testid": dataTestId || 'ds-icon',
|
|
28
|
+
"data-icon": resolvedIconName,
|
|
29
|
+
"data-icon-size": size,
|
|
30
|
+
"data-icon-color": color,
|
|
31
|
+
"data-icon-stroke": stroke,
|
|
32
|
+
title: resolvedIconName
|
|
33
|
+
}, component || resolvedIconName || 'Icon');
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Factory function for Icon mock with custom render function.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* vi.mock('@synerise/ds-icon', iconWithRenderMockFactory((props) => (
|
|
44
|
+
* <span data-custom-icon={props.iconName}>{props.iconName}</span>
|
|
45
|
+
* )));
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export var iconWithRenderMockFactory = function iconWithRenderMockFactory(renderFn) {
|
|
49
|
+
return function () {
|
|
50
|
+
return {
|
|
51
|
+
"default": vi.fn(renderFn)
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Factory function for minimal Icon mock.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* vi.mock('@synerise/ds-icon', iconMinimalMockFactory);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export var iconMinimalMockFactory = function iconMinimalMockFactory() {
|
|
65
|
+
return {
|
|
66
|
+
"default": vi.fn(function () {
|
|
67
|
+
return null;
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockInput = function mockInput() {
|
|
3
|
+
jest.mock('@synerise/ds-input', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var value = _ref.value,
|
|
8
|
+
defaultValue = _ref.defaultValue,
|
|
9
|
+
onChange = _ref.onChange,
|
|
10
|
+
onBlur = _ref.onBlur,
|
|
11
|
+
onFocus = _ref.onFocus,
|
|
12
|
+
placeholder = _ref.placeholder,
|
|
13
|
+
disabled = _ref.disabled,
|
|
14
|
+
error = _ref.error,
|
|
15
|
+
className = _ref.className,
|
|
16
|
+
dataTestId = _ref['data-testid'];
|
|
17
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
18
|
+
className: "ds-input " + (className || ''),
|
|
19
|
+
"data-testid": dataTestId || 'ds-input',
|
|
20
|
+
"data-error": error,
|
|
21
|
+
value: value,
|
|
22
|
+
defaultValue: defaultValue,
|
|
23
|
+
onChange: onChange,
|
|
24
|
+
onBlur: onBlur,
|
|
25
|
+
onFocus: onFocus,
|
|
26
|
+
placeholder: placeholder,
|
|
27
|
+
disabled: disabled
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
TextArea: jest.fn(function (_ref2) {
|
|
31
|
+
var value = _ref2.value,
|
|
32
|
+
onChange = _ref2.onChange,
|
|
33
|
+
placeholder = _ref2.placeholder,
|
|
34
|
+
disabled = _ref2.disabled,
|
|
35
|
+
dataTestId = _ref2['data-testid'];
|
|
36
|
+
return /*#__PURE__*/React.createElement("textarea", {
|
|
37
|
+
"data-testid": dataTestId || 'ds-textarea',
|
|
38
|
+
value: value,
|
|
39
|
+
onChange: onChange,
|
|
40
|
+
placeholder: placeholder,
|
|
41
|
+
disabled: disabled
|
|
42
|
+
});
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
export var mockInputMinimal = function mockInputMinimal() {
|
|
48
|
+
jest.mock('@synerise/ds-input', function () {
|
|
49
|
+
return {
|
|
50
|
+
__esModule: true,
|
|
51
|
+
"default": jest.fn(function () {
|
|
52
|
+
return null;
|
|
53
|
+
}),
|
|
54
|
+
TextArea: jest.fn(function () {
|
|
55
|
+
return null;
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { InputProps } from '@synerise/ds-input';
|
|
3
|
+
export type MockInputProps = InputProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Input mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { inputMockFactory } from '@synerise/ds-mocks/Input/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-input', inputMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const inputMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ value, defaultValue, onChange, onBlur, onFocus, placeholder, disabled, error, className, "data-testid": dataTestId, }: MockInputProps) => React.JSX.Element>;
|
|
19
|
+
TextArea: import("vitest").Mock<({ value, onChange, placeholder, disabled, "data-testid": dataTestId, }: MockInputProps) => React.JSX.Element>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Factory function for minimal Input mock.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* vi.mock('@synerise/ds-input', inputMinimalMockFactory);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const inputMinimalMockFactory: () => {
|
|
30
|
+
default: import("vitest").Mock<() => null>;
|
|
31
|
+
TextArea: import("vitest").Mock<() => null>;
|
|
32
|
+
};
|
package/dist/Input/vi.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Input mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { inputMockFactory } from '@synerise/ds-mocks/Input/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-input', inputMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var inputMockFactory = function inputMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var value = _ref.value,
|
|
17
|
+
defaultValue = _ref.defaultValue,
|
|
18
|
+
onChange = _ref.onChange,
|
|
19
|
+
onBlur = _ref.onBlur,
|
|
20
|
+
onFocus = _ref.onFocus,
|
|
21
|
+
placeholder = _ref.placeholder,
|
|
22
|
+
disabled = _ref.disabled,
|
|
23
|
+
error = _ref.error,
|
|
24
|
+
className = _ref.className,
|
|
25
|
+
dataTestId = _ref['data-testid'];
|
|
26
|
+
return /*#__PURE__*/React.createElement("input", {
|
|
27
|
+
className: "ds-input " + (className || ''),
|
|
28
|
+
"data-testid": dataTestId || 'ds-input',
|
|
29
|
+
"data-error": error,
|
|
30
|
+
value: value,
|
|
31
|
+
defaultValue: defaultValue,
|
|
32
|
+
onChange: onChange,
|
|
33
|
+
onBlur: onBlur,
|
|
34
|
+
onFocus: onFocus,
|
|
35
|
+
placeholder: placeholder,
|
|
36
|
+
disabled: disabled
|
|
37
|
+
});
|
|
38
|
+
}),
|
|
39
|
+
TextArea: vi.fn(function (_ref2) {
|
|
40
|
+
var value = _ref2.value,
|
|
41
|
+
onChange = _ref2.onChange,
|
|
42
|
+
placeholder = _ref2.placeholder,
|
|
43
|
+
disabled = _ref2.disabled,
|
|
44
|
+
dataTestId = _ref2['data-testid'];
|
|
45
|
+
return /*#__PURE__*/React.createElement("textarea", {
|
|
46
|
+
"data-testid": dataTestId || 'ds-textarea',
|
|
47
|
+
value: value,
|
|
48
|
+
onChange: onChange,
|
|
49
|
+
placeholder: placeholder,
|
|
50
|
+
disabled: disabled
|
|
51
|
+
});
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Factory function for minimal Input mock.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* vi.mock('@synerise/ds-input', inputMinimalMockFactory);
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export var inputMinimalMockFactory = function inputMinimalMockFactory() {
|
|
65
|
+
return {
|
|
66
|
+
"default": vi.fn(function () {
|
|
67
|
+
return null;
|
|
68
|
+
}),
|
|
69
|
+
TextArea: vi.fn(function () {
|
|
70
|
+
return null;
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockModal = function mockModal() {
|
|
3
|
+
jest.mock('@synerise/ds-modal', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var open = _ref.open,
|
|
8
|
+
visible = _ref.visible,
|
|
9
|
+
title = _ref.title,
|
|
10
|
+
children = _ref.children,
|
|
11
|
+
onCancel = _ref.onCancel,
|
|
12
|
+
onOk = _ref.onOk,
|
|
13
|
+
footer = _ref.footer,
|
|
14
|
+
_ref$closable = _ref.closable,
|
|
15
|
+
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
16
|
+
size = _ref.size,
|
|
17
|
+
texts = _ref.texts,
|
|
18
|
+
dataTestId = _ref['data-testid'];
|
|
19
|
+
var isOpen = open != null ? open : visible;
|
|
20
|
+
if (!isOpen) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
var testId = dataTestId || 'ds-modal';
|
|
24
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
25
|
+
"data-testid": testId,
|
|
26
|
+
className: "ds-modal",
|
|
27
|
+
"data-size": size,
|
|
28
|
+
role: "dialog"
|
|
29
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
"data-testid": testId + "-header"
|
|
31
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
"data-testid": testId + "-title"
|
|
33
|
+
}, title), closable && /*#__PURE__*/React.createElement("button", {
|
|
34
|
+
"data-testid": testId + "-close",
|
|
35
|
+
onClick: onCancel,
|
|
36
|
+
"aria-label": "Close"
|
|
37
|
+
}, "\xD7")), /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
"data-testid": testId + "-body"
|
|
39
|
+
}, children), footer !== null && /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
"data-testid": testId + "-footer"
|
|
41
|
+
}, footer || /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
42
|
+
"data-testid": testId + "-cancel",
|
|
43
|
+
onClick: onCancel
|
|
44
|
+
}, (texts == null ? void 0 : texts.cancelButton) || 'Cancel'), /*#__PURE__*/React.createElement("button", {
|
|
45
|
+
"data-testid": testId + "-ok",
|
|
46
|
+
onClick: onOk
|
|
47
|
+
}, (texts == null ? void 0 : texts.okButton) || 'OK'))));
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
export var mockModalMinimal = function mockModalMinimal() {
|
|
53
|
+
jest.mock('@synerise/ds-modal', function () {
|
|
54
|
+
return {
|
|
55
|
+
__esModule: true,
|
|
56
|
+
"default": jest.fn(function (_ref2) {
|
|
57
|
+
var open = _ref2.open,
|
|
58
|
+
visible = _ref2.visible,
|
|
59
|
+
children = _ref2.children;
|
|
60
|
+
var isOpen = open != null ? open : visible;
|
|
61
|
+
return isOpen ? /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
"data-testid": "ds-modal"
|
|
63
|
+
}, children) : null;
|
|
64
|
+
})
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ModalProps } from '@synerise/ds-modal';
|
|
3
|
+
export type MockModalProps = ModalProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Modal mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { modalMockFactory } from '@synerise/ds-mocks/Modal/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-modal', modalMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const modalMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ open, visible, title, children, onCancel, onOk, footer, closable, size, texts, "data-testid": dataTestId, }: MockModalProps) => React.JSX.Element | null>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Factory function for minimal Modal mock.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* vi.mock('@synerise/ds-modal', modalMinimalMockFactory);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const modalMinimalMockFactory: () => {
|
|
29
|
+
default: import("vitest").Mock<({ open, visible, children }: MockModalProps) => React.JSX.Element | null>;
|
|
30
|
+
};
|
package/dist/Modal/vi.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Modal mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { modalMockFactory } from '@synerise/ds-mocks/Modal/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-modal', modalMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var modalMockFactory = function modalMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var open = _ref.open,
|
|
17
|
+
visible = _ref.visible,
|
|
18
|
+
title = _ref.title,
|
|
19
|
+
children = _ref.children,
|
|
20
|
+
onCancel = _ref.onCancel,
|
|
21
|
+
onOk = _ref.onOk,
|
|
22
|
+
footer = _ref.footer,
|
|
23
|
+
_ref$closable = _ref.closable,
|
|
24
|
+
closable = _ref$closable === void 0 ? true : _ref$closable,
|
|
25
|
+
size = _ref.size,
|
|
26
|
+
texts = _ref.texts,
|
|
27
|
+
dataTestId = _ref['data-testid'];
|
|
28
|
+
var isOpen = open != null ? open : visible;
|
|
29
|
+
if (!isOpen) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
var testId = dataTestId || 'ds-modal';
|
|
33
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
"data-testid": testId,
|
|
35
|
+
className: "ds-modal",
|
|
36
|
+
"data-size": size,
|
|
37
|
+
role: "dialog"
|
|
38
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
39
|
+
"data-testid": testId + "-header"
|
|
40
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
41
|
+
"data-testid": testId + "-title"
|
|
42
|
+
}, title), closable && /*#__PURE__*/React.createElement("button", {
|
|
43
|
+
"data-testid": testId + "-close",
|
|
44
|
+
onClick: onCancel,
|
|
45
|
+
"aria-label": "Close"
|
|
46
|
+
}, "\xD7")), /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
"data-testid": testId + "-body"
|
|
48
|
+
}, children), footer !== null && /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
"data-testid": testId + "-footer"
|
|
50
|
+
}, footer || /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
51
|
+
"data-testid": testId + "-cancel",
|
|
52
|
+
onClick: onCancel
|
|
53
|
+
}, (texts == null ? void 0 : texts.cancelButton) || 'Cancel'), /*#__PURE__*/React.createElement("button", {
|
|
54
|
+
"data-testid": testId + "-ok",
|
|
55
|
+
onClick: onOk
|
|
56
|
+
}, (texts == null ? void 0 : texts.okButton) || 'OK'))));
|
|
57
|
+
})
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Factory function for minimal Modal mock.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* vi.mock('@synerise/ds-modal', modalMinimalMockFactory);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export var modalMinimalMockFactory = function modalMinimalMockFactory() {
|
|
70
|
+
return {
|
|
71
|
+
"default": vi.fn(function (_ref2) {
|
|
72
|
+
var open = _ref2.open,
|
|
73
|
+
visible = _ref2.visible,
|
|
74
|
+
children = _ref2.children;
|
|
75
|
+
var isOpen = open != null ? open : visible;
|
|
76
|
+
return isOpen ? /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
"data-testid": "ds-modal"
|
|
78
|
+
}, children) : null;
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockSelect = function mockSelect() {
|
|
3
|
+
jest.mock('@synerise/ds-select', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var value = _ref.value,
|
|
8
|
+
defaultValue = _ref.defaultValue,
|
|
9
|
+
_onChange = _ref.onChange,
|
|
10
|
+
onSelect = _ref.onSelect,
|
|
11
|
+
placeholder = _ref.placeholder,
|
|
12
|
+
disabled = _ref.disabled,
|
|
13
|
+
error = _ref.error,
|
|
14
|
+
options = _ref.options,
|
|
15
|
+
children = _ref.children,
|
|
16
|
+
className = _ref.className,
|
|
17
|
+
dataTestId = _ref['data-testid'];
|
|
18
|
+
return /*#__PURE__*/React.createElement("select", {
|
|
19
|
+
className: "ds-select " + (className || ''),
|
|
20
|
+
"data-testid": dataTestId || 'ds-select',
|
|
21
|
+
"data-error": error,
|
|
22
|
+
value: value,
|
|
23
|
+
defaultValue: defaultValue,
|
|
24
|
+
onChange: function onChange(e) {
|
|
25
|
+
_onChange == null || _onChange(e.target.value, {
|
|
26
|
+
value: e.target.value,
|
|
27
|
+
label: e.target.value
|
|
28
|
+
});
|
|
29
|
+
onSelect == null || onSelect(e.target.value, {
|
|
30
|
+
value: e.target.value,
|
|
31
|
+
label: e.target.value
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
disabled: disabled
|
|
35
|
+
}, placeholder && /*#__PURE__*/React.createElement("option", {
|
|
36
|
+
value: ""
|
|
37
|
+
}, placeholder), options == null ? void 0 : options.map(
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
function (opt, idx) {
|
|
40
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
41
|
+
key: idx,
|
|
42
|
+
value: String(opt.value)
|
|
43
|
+
}, opt.label);
|
|
44
|
+
}), children);
|
|
45
|
+
}),
|
|
46
|
+
Option: jest.fn(function (_ref2) {
|
|
47
|
+
var value = _ref2.value,
|
|
48
|
+
children = _ref2.children;
|
|
49
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
50
|
+
value: String(value)
|
|
51
|
+
}, children);
|
|
52
|
+
})
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
export var mockSelectMinimal = function mockSelectMinimal() {
|
|
57
|
+
jest.mock('@synerise/ds-select', function () {
|
|
58
|
+
return {
|
|
59
|
+
__esModule: true,
|
|
60
|
+
"default": jest.fn(function () {
|
|
61
|
+
return null;
|
|
62
|
+
}),
|
|
63
|
+
Option: jest.fn(function () {
|
|
64
|
+
return null;
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { SelectProps } from '@synerise/ds-select';
|
|
3
|
+
export type MockSelectProps = SelectProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Select mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { selectMockFactory } from '@synerise/ds-mocks/Select/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-select', selectMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const selectMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ value, defaultValue, onChange, onSelect, placeholder, disabled, error, options, children, className, "data-testid": dataTestId, }: MockSelectProps) => React.JSX.Element>;
|
|
19
|
+
Option: import("vitest").Mock<({ value, children }: {
|
|
20
|
+
value: unknown;
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}) => React.JSX.Element>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Factory function for minimal Select mock.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* vi.mock('@synerise/ds-select', selectMinimalMockFactory);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare const selectMinimalMockFactory: () => {
|
|
33
|
+
default: import("vitest").Mock<() => null>;
|
|
34
|
+
Option: import("vitest").Mock<() => null>;
|
|
35
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Select mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { selectMockFactory } from '@synerise/ds-mocks/Select/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-select', selectMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var selectMockFactory = function selectMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var value = _ref.value,
|
|
17
|
+
defaultValue = _ref.defaultValue,
|
|
18
|
+
_onChange = _ref.onChange,
|
|
19
|
+
onSelect = _ref.onSelect,
|
|
20
|
+
placeholder = _ref.placeholder,
|
|
21
|
+
disabled = _ref.disabled,
|
|
22
|
+
error = _ref.error,
|
|
23
|
+
options = _ref.options,
|
|
24
|
+
children = _ref.children,
|
|
25
|
+
className = _ref.className,
|
|
26
|
+
dataTestId = _ref['data-testid'];
|
|
27
|
+
return /*#__PURE__*/React.createElement("select", {
|
|
28
|
+
className: "ds-select " + (className || ''),
|
|
29
|
+
"data-testid": dataTestId || 'ds-select',
|
|
30
|
+
"data-error": error,
|
|
31
|
+
value: value,
|
|
32
|
+
defaultValue: defaultValue,
|
|
33
|
+
onChange: function onChange(e) {
|
|
34
|
+
_onChange == null || _onChange(e.target.value, {
|
|
35
|
+
value: e.target.value,
|
|
36
|
+
label: e.target.value
|
|
37
|
+
});
|
|
38
|
+
onSelect == null || onSelect(e.target.value, {
|
|
39
|
+
value: e.target.value,
|
|
40
|
+
label: e.target.value
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
disabled: disabled
|
|
44
|
+
}, placeholder && /*#__PURE__*/React.createElement("option", {
|
|
45
|
+
value: ""
|
|
46
|
+
}, placeholder), options == null ? void 0 : options.map(
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
function (opt, idx) {
|
|
49
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
50
|
+
key: idx,
|
|
51
|
+
value: String(opt.value)
|
|
52
|
+
}, opt.label);
|
|
53
|
+
}), children);
|
|
54
|
+
}),
|
|
55
|
+
Option: vi.fn(function (_ref2) {
|
|
56
|
+
var value = _ref2.value,
|
|
57
|
+
children = _ref2.children;
|
|
58
|
+
return /*#__PURE__*/React.createElement("option", {
|
|
59
|
+
value: String(value)
|
|
60
|
+
}, children);
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Factory function for minimal Select mock.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* vi.mock('@synerise/ds-select', selectMinimalMockFactory);
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export var selectMinimalMockFactory = function selectMinimalMockFactory() {
|
|
74
|
+
return {
|
|
75
|
+
"default": vi.fn(function () {
|
|
76
|
+
return null;
|
|
77
|
+
}),
|
|
78
|
+
Option: vi.fn(function () {
|
|
79
|
+
return null;
|
|
80
|
+
})
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|