@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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var getDataIndex = function getDataIndex(dataIndex) {
|
|
3
|
+
if (Array.isArray(dataIndex)) {
|
|
4
|
+
return dataIndex.join('.');
|
|
5
|
+
}
|
|
6
|
+
return String(dataIndex != null ? dataIndex : '');
|
|
7
|
+
};
|
|
8
|
+
export var mockTable = function mockTable() {
|
|
9
|
+
jest.mock('@synerise/ds-table', function () {
|
|
10
|
+
return {
|
|
11
|
+
__esModule: true,
|
|
12
|
+
"default": jest.fn(function (_ref) {
|
|
13
|
+
var _ref$dataSource = _ref.dataSource,
|
|
14
|
+
dataSource = _ref$dataSource === void 0 ? [] : _ref$dataSource,
|
|
15
|
+
_ref$columns = _ref.columns,
|
|
16
|
+
columns = _ref$columns === void 0 ? [] : _ref$columns,
|
|
17
|
+
loading = _ref.loading,
|
|
18
|
+
_ref$rowKey = _ref.rowKey,
|
|
19
|
+
rowKey = _ref$rowKey === void 0 ? 'key' : _ref$rowKey,
|
|
20
|
+
onRow = _ref.onRow,
|
|
21
|
+
rowSelection = _ref.rowSelection,
|
|
22
|
+
title = _ref.title,
|
|
23
|
+
dataTestId = _ref['data-testid'];
|
|
24
|
+
var testId = dataTestId || 'ds-table';
|
|
25
|
+
var getRowKey = function getRowKey(record, index) {
|
|
26
|
+
var _record$rowKey;
|
|
27
|
+
if (typeof rowKey === 'function') {
|
|
28
|
+
return rowKey(record);
|
|
29
|
+
}
|
|
30
|
+
return String((_record$rowKey = record[rowKey]) != null ? _record$rowKey : index);
|
|
31
|
+
};
|
|
32
|
+
var renderTitle = function renderTitle(t) {
|
|
33
|
+
if (typeof t === 'function') {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return t;
|
|
37
|
+
};
|
|
38
|
+
var renderColumnTitle = function renderColumnTitle(colTitle) {
|
|
39
|
+
if (typeof colTitle === 'function') {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
return colTitle;
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
45
|
+
"data-testid": testId,
|
|
46
|
+
className: "ds-table",
|
|
47
|
+
"data-loading": loading
|
|
48
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
"data-testid": testId + "-title"
|
|
50
|
+
}, renderTitle(title)), loading ? /*#__PURE__*/React.createElement("div", {
|
|
51
|
+
"data-testid": testId + "-loading"
|
|
52
|
+
}, "Loading...") : /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", {
|
|
53
|
+
"data-testid": testId + "-header"
|
|
54
|
+
}, rowSelection && /*#__PURE__*/React.createElement("th", null, "Select"), columns.map(
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
function (col, idx) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
58
|
+
key: col.key || idx,
|
|
59
|
+
"data-testid": testId + "-header-" + (getDataIndex(col.dataIndex) || idx)
|
|
60
|
+
}, renderColumnTitle(col.title));
|
|
61
|
+
}))), /*#__PURE__*/React.createElement("tbody", null, dataSource.map(
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
|
+
function (record, rowIndex) {
|
|
64
|
+
var _rowSelection$selecte;
|
|
65
|
+
var key = getRowKey(record, rowIndex);
|
|
66
|
+
var rowProps = onRow == null ? void 0 : onRow(record, rowIndex);
|
|
67
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
68
|
+
key: key,
|
|
69
|
+
"data-testid": testId + "-row-" + rowIndex,
|
|
70
|
+
onClick: rowProps == null ? void 0 : rowProps.onClick
|
|
71
|
+
}, rowSelection && /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", {
|
|
72
|
+
type: "checkbox",
|
|
73
|
+
"data-testid": testId + "-checkbox-" + rowIndex,
|
|
74
|
+
checked: (_rowSelection$selecte = rowSelection.selectedRowKeys) == null ? void 0 : _rowSelection$selecte.includes(key),
|
|
75
|
+
onChange: function onChange() {
|
|
76
|
+
var _rowSelection$selecte2;
|
|
77
|
+
var newKeys = (_rowSelection$selecte2 = rowSelection.selectedRowKeys) != null && _rowSelection$selecte2.includes(key) ? rowSelection.selectedRowKeys.filter(
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
|
+
function (k) {
|
|
80
|
+
return k !== key;
|
|
81
|
+
}) : [].concat(rowSelection.selectedRowKeys || [], [key]);
|
|
82
|
+
rowSelection.onChange == null || rowSelection.onChange(newKeys, [], {
|
|
83
|
+
type: 'all'
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
})), columns.map(
|
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
|
+
function (col, colIndex) {
|
|
89
|
+
var dataIdx = getDataIndex(col.dataIndex);
|
|
90
|
+
var cellValue = record[dataIdx];
|
|
91
|
+
var rendered = col.render ? col.render(cellValue, record, rowIndex) : cellValue;
|
|
92
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
93
|
+
key: col.key || colIndex,
|
|
94
|
+
"data-testid": testId + "-cell-" + rowIndex + "-" + colIndex
|
|
95
|
+
}, String(rendered != null ? rendered : ''));
|
|
96
|
+
}));
|
|
97
|
+
}))));
|
|
98
|
+
})
|
|
99
|
+
};
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
export var mockTableMinimal = function mockTableMinimal() {
|
|
103
|
+
jest.mock('@synerise/ds-table', function () {
|
|
104
|
+
return {
|
|
105
|
+
__esModule: true,
|
|
106
|
+
"default": jest.fn(function () {
|
|
107
|
+
return null;
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DSTableProps } from '@synerise/ds-table';
|
|
3
|
+
export type MockTableProps = DSTableProps<Record<string, unknown>> & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Table mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { tableMockFactory } from '@synerise/ds-mocks/Table/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-table', tableMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const tableMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ dataSource, columns, loading, rowKey, onRow, rowSelection, title, "data-testid": dataTestId, }: MockTableProps) => React.JSX.Element>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Factory function for minimal Table mock.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* vi.mock('@synerise/ds-table', tableMinimalMockFactory);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const tableMinimalMockFactory: () => {
|
|
29
|
+
default: import("vitest").Mock<() => null>;
|
|
30
|
+
};
|
package/dist/Table/vi.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
var getDataIndex = function getDataIndex(dataIndex) {
|
|
3
|
+
if (Array.isArray(dataIndex)) {
|
|
4
|
+
return dataIndex.join('.');
|
|
5
|
+
}
|
|
6
|
+
return String(dataIndex != null ? dataIndex : '');
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Factory function for Table mock.
|
|
11
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { tableMockFactory } from '@synerise/ds-mocks/Table/vi';
|
|
16
|
+
*
|
|
17
|
+
* vi.mock('@synerise/ds-table', tableMockFactory);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export var tableMockFactory = function tableMockFactory() {
|
|
21
|
+
return {
|
|
22
|
+
"default": vi.fn(function (_ref) {
|
|
23
|
+
var _ref$dataSource = _ref.dataSource,
|
|
24
|
+
dataSource = _ref$dataSource === void 0 ? [] : _ref$dataSource,
|
|
25
|
+
_ref$columns = _ref.columns,
|
|
26
|
+
columns = _ref$columns === void 0 ? [] : _ref$columns,
|
|
27
|
+
loading = _ref.loading,
|
|
28
|
+
_ref$rowKey = _ref.rowKey,
|
|
29
|
+
rowKey = _ref$rowKey === void 0 ? 'key' : _ref$rowKey,
|
|
30
|
+
onRow = _ref.onRow,
|
|
31
|
+
rowSelection = _ref.rowSelection,
|
|
32
|
+
title = _ref.title,
|
|
33
|
+
dataTestId = _ref['data-testid'];
|
|
34
|
+
var testId = dataTestId || 'ds-table';
|
|
35
|
+
var getRowKey = function getRowKey(record, index) {
|
|
36
|
+
var _record$rowKey;
|
|
37
|
+
if (typeof rowKey === 'function') {
|
|
38
|
+
return rowKey(record);
|
|
39
|
+
}
|
|
40
|
+
return String((_record$rowKey = record[rowKey]) != null ? _record$rowKey : index);
|
|
41
|
+
};
|
|
42
|
+
var renderTitle = function renderTitle(t) {
|
|
43
|
+
if (typeof t === 'function') {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return t;
|
|
47
|
+
};
|
|
48
|
+
var renderColumnTitle = function renderColumnTitle(colTitle) {
|
|
49
|
+
if (typeof colTitle === 'function') {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return colTitle;
|
|
53
|
+
};
|
|
54
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
55
|
+
"data-testid": testId,
|
|
56
|
+
className: "ds-table",
|
|
57
|
+
"data-loading": loading
|
|
58
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
"data-testid": testId + "-title"
|
|
60
|
+
}, renderTitle(title)), loading ? /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
"data-testid": testId + "-loading"
|
|
62
|
+
}, "Loading...") : /*#__PURE__*/React.createElement("table", null, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", {
|
|
63
|
+
"data-testid": testId + "-header"
|
|
64
|
+
}, rowSelection && /*#__PURE__*/React.createElement("th", null, "Select"), columns.map(
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
function (col, idx) {
|
|
67
|
+
return /*#__PURE__*/React.createElement("th", {
|
|
68
|
+
key: col.key || idx,
|
|
69
|
+
"data-testid": testId + "-header-" + (getDataIndex(col.dataIndex) || idx)
|
|
70
|
+
}, renderColumnTitle(col.title));
|
|
71
|
+
}))), /*#__PURE__*/React.createElement("tbody", null, dataSource.map(
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
73
|
+
function (record, rowIndex) {
|
|
74
|
+
var _rowSelection$selecte;
|
|
75
|
+
var key = getRowKey(record, rowIndex);
|
|
76
|
+
var rowProps = onRow == null ? void 0 : onRow(record, rowIndex);
|
|
77
|
+
return /*#__PURE__*/React.createElement("tr", {
|
|
78
|
+
key: key,
|
|
79
|
+
"data-testid": testId + "-row-" + rowIndex,
|
|
80
|
+
onClick: rowProps == null ? void 0 : rowProps.onClick
|
|
81
|
+
}, rowSelection && /*#__PURE__*/React.createElement("td", null, /*#__PURE__*/React.createElement("input", {
|
|
82
|
+
type: "checkbox",
|
|
83
|
+
"data-testid": testId + "-checkbox-" + rowIndex,
|
|
84
|
+
checked: (_rowSelection$selecte = rowSelection.selectedRowKeys) == null ? void 0 : _rowSelection$selecte.includes(key),
|
|
85
|
+
onChange: function onChange() {
|
|
86
|
+
var _rowSelection$selecte2;
|
|
87
|
+
var newKeys = (_rowSelection$selecte2 = rowSelection.selectedRowKeys) != null && _rowSelection$selecte2.includes(key) ? rowSelection.selectedRowKeys.filter(
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
function (k) {
|
|
90
|
+
return k !== key;
|
|
91
|
+
}) : [].concat(rowSelection.selectedRowKeys || [], [key]);
|
|
92
|
+
rowSelection.onChange == null || rowSelection.onChange(newKeys, [], {
|
|
93
|
+
type: 'all'
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
})), columns.map(
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
function (col, colIndex) {
|
|
99
|
+
var dataIdx = getDataIndex(col.dataIndex);
|
|
100
|
+
var cellValue = record[dataIdx];
|
|
101
|
+
var rendered = col.render ? col.render(cellValue, record, rowIndex) : cellValue;
|
|
102
|
+
return /*#__PURE__*/React.createElement("td", {
|
|
103
|
+
key: col.key || colIndex,
|
|
104
|
+
"data-testid": testId + "-cell-" + rowIndex + "-" + colIndex
|
|
105
|
+
}, String(rendered != null ? rendered : ''));
|
|
106
|
+
}));
|
|
107
|
+
}))));
|
|
108
|
+
})
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Factory function for minimal Table mock.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* vi.mock('@synerise/ds-table', tableMinimalMockFactory);
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export var tableMinimalMockFactory = function tableMinimalMockFactory() {
|
|
121
|
+
return {
|
|
122
|
+
"default": vi.fn(function () {
|
|
123
|
+
return null;
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockTabs = function mockTabs() {
|
|
3
|
+
jest.mock('@synerise/ds-tabs', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var _ref$activeTab = _ref.activeTab,
|
|
8
|
+
activeTab = _ref$activeTab === void 0 ? 0 : _ref$activeTab,
|
|
9
|
+
_ref$tabs = _ref.tabs,
|
|
10
|
+
tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
|
|
11
|
+
handleTabClick = _ref.handleTabClick,
|
|
12
|
+
underscore = _ref.underscore,
|
|
13
|
+
block = _ref.block,
|
|
14
|
+
dataTestId = _ref['data-testid'];
|
|
15
|
+
var testId = dataTestId || 'ds-tabs';
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
"data-testid": testId,
|
|
18
|
+
className: "ds-tabs",
|
|
19
|
+
"data-underscore": underscore,
|
|
20
|
+
"data-block": block
|
|
21
|
+
}, tabs.map(function (tab, index) {
|
|
22
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
23
|
+
key: index,
|
|
24
|
+
"data-testid": testId + "-tab-" + index,
|
|
25
|
+
"data-active": activeTab === index,
|
|
26
|
+
disabled: tab.disabled,
|
|
27
|
+
onClick: function onClick() {
|
|
28
|
+
return handleTabClick == null ? void 0 : handleTabClick(index);
|
|
29
|
+
},
|
|
30
|
+
className: activeTab === index ? 'active' : ''
|
|
31
|
+
}, tab.icon, tab.label);
|
|
32
|
+
}));
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
export var mockTabsMinimal = function mockTabsMinimal() {
|
|
38
|
+
jest.mock('@synerise/ds-tabs', function () {
|
|
39
|
+
return {
|
|
40
|
+
__esModule: true,
|
|
41
|
+
"default": jest.fn(function () {
|
|
42
|
+
return null;
|
|
43
|
+
})
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TabItem, TabsProps } from '@synerise/ds-tabs';
|
|
3
|
+
export type { TabItem };
|
|
4
|
+
export type MockTabsProps = TabsProps & {
|
|
5
|
+
'data-testid'?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Factory function for Tabs mock.
|
|
9
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { tabsMockFactory } from '@synerise/ds-mocks/Tabs/vi';
|
|
14
|
+
*
|
|
15
|
+
* vi.mock('@synerise/ds-tabs', tabsMockFactory);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const tabsMockFactory: () => {
|
|
19
|
+
default: import("vitest").Mock<({ activeTab, tabs, handleTabClick, underscore, block, "data-testid": dataTestId, }: MockTabsProps) => React.JSX.Element>;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Factory function for minimal Tabs mock.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* vi.mock('@synerise/ds-tabs', tabsMinimalMockFactory);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const tabsMinimalMockFactory: () => {
|
|
30
|
+
default: import("vitest").Mock<() => null>;
|
|
31
|
+
};
|
package/dist/Tabs/vi.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Tabs mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { tabsMockFactory } from '@synerise/ds-mocks/Tabs/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-tabs', tabsMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var tabsMockFactory = function tabsMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var _ref$activeTab = _ref.activeTab,
|
|
17
|
+
activeTab = _ref$activeTab === void 0 ? 0 : _ref$activeTab,
|
|
18
|
+
_ref$tabs = _ref.tabs,
|
|
19
|
+
tabs = _ref$tabs === void 0 ? [] : _ref$tabs,
|
|
20
|
+
handleTabClick = _ref.handleTabClick,
|
|
21
|
+
underscore = _ref.underscore,
|
|
22
|
+
block = _ref.block,
|
|
23
|
+
dataTestId = _ref['data-testid'];
|
|
24
|
+
var testId = dataTestId || 'ds-tabs';
|
|
25
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
26
|
+
"data-testid": testId,
|
|
27
|
+
className: "ds-tabs",
|
|
28
|
+
"data-underscore": underscore,
|
|
29
|
+
"data-block": block
|
|
30
|
+
}, tabs.map(function (tab, index) {
|
|
31
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
32
|
+
key: index,
|
|
33
|
+
"data-testid": testId + "-tab-" + index,
|
|
34
|
+
"data-active": activeTab === index,
|
|
35
|
+
disabled: tab.disabled,
|
|
36
|
+
onClick: function onClick() {
|
|
37
|
+
return handleTabClick == null ? void 0 : handleTabClick(index);
|
|
38
|
+
},
|
|
39
|
+
className: activeTab === index ? 'active' : ''
|
|
40
|
+
}, tab.icon, tab.label);
|
|
41
|
+
}));
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Factory function for minimal Tabs mock.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```typescript
|
|
51
|
+
* vi.mock('@synerise/ds-tabs', tabsMinimalMockFactory);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export var tabsMinimalMockFactory = function tabsMinimalMockFactory() {
|
|
55
|
+
return {
|
|
56
|
+
"default": vi.fn(function () {
|
|
57
|
+
return null;
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TooltipProps } from '@synerise/ds-tooltip';
|
|
2
|
+
export type MockTooltipProps = TooltipProps & {
|
|
3
|
+
'data-testid'?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const mockTooltip: (options?: {
|
|
6
|
+
showContent?: boolean;
|
|
7
|
+
}) => void;
|
|
8
|
+
export declare const mockTooltipMinimal: () => void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockTooltip = function mockTooltip(options) {
|
|
3
|
+
if (options === void 0) {
|
|
4
|
+
options = {};
|
|
5
|
+
}
|
|
6
|
+
jest.mock('@synerise/ds-tooltip', function () {
|
|
7
|
+
return {
|
|
8
|
+
__esModule: true,
|
|
9
|
+
"default": jest.fn(function (_ref) {
|
|
10
|
+
var children = _ref.children,
|
|
11
|
+
title = _ref.title,
|
|
12
|
+
description = _ref.description,
|
|
13
|
+
type = _ref.type,
|
|
14
|
+
dataTestId = _ref['data-testid'];
|
|
15
|
+
var testId = dataTestId || 'ds-tooltip';
|
|
16
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
17
|
+
"data-testid": testId,
|
|
18
|
+
"data-tooltip-type": type
|
|
19
|
+
}, children, options.showContent && (title || description) && /*#__PURE__*/React.createElement("div", {
|
|
20
|
+
"data-testid": testId + "-content"
|
|
21
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
22
|
+
"data-testid": testId + "-title"
|
|
23
|
+
}, title), description && /*#__PURE__*/React.createElement("div", {
|
|
24
|
+
"data-testid": testId + "-description"
|
|
25
|
+
}, description)));
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
export var mockTooltipMinimal = function mockTooltipMinimal() {
|
|
31
|
+
jest.mock('@synerise/ds-tooltip', function () {
|
|
32
|
+
return {
|
|
33
|
+
__esModule: true,
|
|
34
|
+
"default": jest.fn(function (_ref2) {
|
|
35
|
+
var children = _ref2.children;
|
|
36
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TooltipProps } from '@synerise/ds-tooltip';
|
|
3
|
+
export type MockTooltipProps = TooltipProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Tooltip mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { tooltipMockFactory } from '@synerise/ds-mocks/Tooltip/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-tooltip', tooltipMockFactory());
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const tooltipMockFactory: (options?: {
|
|
18
|
+
showContent?: boolean;
|
|
19
|
+
}) => () => {
|
|
20
|
+
default: import("vitest").Mock<({ children, title, description, type, "data-testid": dataTestId, }: MockTooltipProps) => React.JSX.Element>;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Factory function for minimal Tooltip mock.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* vi.mock('@synerise/ds-tooltip', tooltipMinimalMockFactory);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare const tooltipMinimalMockFactory: () => {
|
|
31
|
+
default: import("vitest").Mock<({ children }: MockTooltipProps) => React.JSX.Element>;
|
|
32
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Tooltip mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { tooltipMockFactory } from '@synerise/ds-mocks/Tooltip/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-tooltip', tooltipMockFactory());
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var tooltipMockFactory = function tooltipMockFactory(options) {
|
|
14
|
+
if (options === void 0) {
|
|
15
|
+
options = {};
|
|
16
|
+
}
|
|
17
|
+
return function () {
|
|
18
|
+
return {
|
|
19
|
+
"default": vi.fn(function (_ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
title = _ref.title,
|
|
22
|
+
description = _ref.description,
|
|
23
|
+
type = _ref.type,
|
|
24
|
+
dataTestId = _ref['data-testid'];
|
|
25
|
+
var testId = dataTestId || 'ds-tooltip';
|
|
26
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
27
|
+
"data-testid": testId,
|
|
28
|
+
"data-tooltip-type": type
|
|
29
|
+
}, children, options.showContent && (title || description) && /*#__PURE__*/React.createElement("div", {
|
|
30
|
+
"data-testid": testId + "-content"
|
|
31
|
+
}, title && /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
"data-testid": testId + "-title"
|
|
33
|
+
}, title), description && /*#__PURE__*/React.createElement("div", {
|
|
34
|
+
"data-testid": testId + "-description"
|
|
35
|
+
}, description)));
|
|
36
|
+
})
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Factory function for minimal Tooltip mock.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* vi.mock('@synerise/ds-tooltip', tooltipMinimalMockFactory);
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export var tooltipMinimalMockFactory = function tooltipMinimalMockFactory() {
|
|
50
|
+
return {
|
|
51
|
+
"default": vi.fn(function (_ref2) {
|
|
52
|
+
var children = _ref2.children;
|
|
53
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
54
|
+
})
|
|
55
|
+
};
|
|
56
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './Button';
|
|
2
|
+
export * from './Input';
|
|
3
|
+
export * from './Modal';
|
|
4
|
+
export * from './Select';
|
|
5
|
+
export * from './Tooltip';
|
|
6
|
+
export * from './Icon';
|
|
7
|
+
export * from './Cruds';
|
|
8
|
+
export * from './Table';
|
|
9
|
+
export * from './Tabs';
|
|
10
|
+
export * from './Dropdown';
|
|
11
|
+
export * from './Form';
|
|
12
|
+
export * as jest from './jest';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './Button';
|
|
2
|
+
export * from './Input';
|
|
3
|
+
export * from './Modal';
|
|
4
|
+
export * from './Select';
|
|
5
|
+
export * from './Tooltip';
|
|
6
|
+
export * from './Icon';
|
|
7
|
+
export * from './Cruds';
|
|
8
|
+
export * from './Table';
|
|
9
|
+
export * from './Tabs';
|
|
10
|
+
export * from './Dropdown';
|
|
11
|
+
export * from './Form';
|
|
12
|
+
import * as _jest from './jest';
|
|
13
|
+
export { _jest as jest };
|
package/dist/jest.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './Button/jest';
|
|
2
|
+
export * from './Input/jest';
|
|
3
|
+
export * from './Modal/jest';
|
|
4
|
+
export * from './Select/jest';
|
|
5
|
+
export * from './Tooltip/jest';
|
|
6
|
+
export * from './Icon/jest';
|
|
7
|
+
export * from './Cruds/jest';
|
|
8
|
+
export * from './Table/jest';
|
|
9
|
+
export * from './Tabs/jest';
|
|
10
|
+
export * from './Dropdown/jest';
|
|
11
|
+
export * from './Form/jest';
|
package/dist/jest.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './Button/jest';
|
|
2
|
+
export * from './Input/jest';
|
|
3
|
+
export * from './Modal/jest';
|
|
4
|
+
export * from './Select/jest';
|
|
5
|
+
export * from './Tooltip/jest';
|
|
6
|
+
export * from './Icon/jest';
|
|
7
|
+
export * from './Cruds/jest';
|
|
8
|
+
export * from './Table/jest';
|
|
9
|
+
export * from './Tabs/jest';
|
|
10
|
+
export * from './Dropdown/jest';
|
|
11
|
+
export * from './Form/jest';
|