@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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# 0.1.0 (2026-02-10)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **mocks:** add base package structure ([f4e5263](https://github.com/Synerise/synerise-design/commit/f4e5263d21675dbb3d040a3efbe84b726e12ddca))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Synerise
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: mocks
|
|
3
|
+
title: Mocks
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @synerise/ds-mocks
|
|
7
|
+
|
|
8
|
+
Testing utilities and mock components for Synerise Design System.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm i @synerise/ds-mocks
|
|
14
|
+
# or
|
|
15
|
+
yarn add @synerise/ds-mocks
|
|
16
|
+
# or
|
|
17
|
+
pnpm add @synerise/ds-mocks
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Vitest Mocks
|
|
21
|
+
|
|
22
|
+
This package provides ready-to-use mocks for Synerise DS components in Vitest tests.
|
|
23
|
+
|
|
24
|
+
### Usage
|
|
25
|
+
|
|
26
|
+
Use factory functions with `vi.mock()` and dynamic import to avoid hoisting issues:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
vi.mock('@synerise/ds-button', async () => {
|
|
30
|
+
const { buttonMockFactory } = await import('@synerise/ds-mocks');
|
|
31
|
+
return { ...buttonMockFactory() };
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
vi.mock('@synerise/ds-modal', async () => {
|
|
35
|
+
const { modalMockFactory } = await import('@synerise/ds-mocks');
|
|
36
|
+
return { ...modalMockFactory() };
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
vi.mock('@synerise/ds-icon', async () => {
|
|
40
|
+
const { iconMockFactory } = await import('@synerise/ds-mocks');
|
|
41
|
+
return { ...iconMockFactory() };
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('MyComponent', () => {
|
|
45
|
+
it('renders button with custom testid', () => {
|
|
46
|
+
render(<MyComponent />);
|
|
47
|
+
|
|
48
|
+
// Default testid
|
|
49
|
+
expect(screen.getByTestId('ds-button')).toBeInTheDocument();
|
|
50
|
+
|
|
51
|
+
// Or custom testid if passed via props
|
|
52
|
+
expect(screen.getByTestId('submit-button')).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('opens modal on click', () => {
|
|
56
|
+
render(<MyComponent />);
|
|
57
|
+
|
|
58
|
+
fireEvent.click(screen.getByTestId('ds-button'));
|
|
59
|
+
|
|
60
|
+
expect(screen.getByTestId('ds-modal')).toBeInTheDocument();
|
|
61
|
+
expect(screen.getByTestId('ds-modal-title')).toHaveTextContent('My Modal');
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Available Mocks
|
|
67
|
+
|
|
68
|
+
| Component | Factory Functions |
|
|
69
|
+
| --------- | ------------------------------------------------------------------------ |
|
|
70
|
+
| Button | `buttonMockFactory`, `buttonMinimalMockFactory` |
|
|
71
|
+
| Cruds | `crudsMockFactory`, `crudsMinimalMockFactory` |
|
|
72
|
+
| Dropdown | `dropdownMockFactory`, `dropdownMinimalMockFactory` |
|
|
73
|
+
| Form | `formMockFactory`, `formMinimalMockFactory` |
|
|
74
|
+
| Icon | `iconMockFactory`, `iconMinimalMockFactory`, `iconWithRenderMockFactory` |
|
|
75
|
+
| Input | `inputMockFactory`, `inputMinimalMockFactory` |
|
|
76
|
+
| Modal | `modalMockFactory`, `modalMinimalMockFactory` |
|
|
77
|
+
| Select | `selectMockFactory`, `selectMinimalMockFactory` |
|
|
78
|
+
| Table | `tableMockFactory`, `tableMinimalMockFactory` |
|
|
79
|
+
| Tabs | `tabsMockFactory`, `tabsMinimalMockFactory` |
|
|
80
|
+
| Tooltip | `tooltipMockFactory`, `tooltipMinimalMockFactory` |
|
|
81
|
+
|
|
82
|
+
### Mock Variants
|
|
83
|
+
|
|
84
|
+
Each component has two factory variants:
|
|
85
|
+
|
|
86
|
+
#### Standard Mock Factory
|
|
87
|
+
|
|
88
|
+
Full-featured mock with all props and data-testid support.
|
|
89
|
+
|
|
90
|
+
```typescript
|
|
91
|
+
vi.mock('@synerise/ds-button', async () => {
|
|
92
|
+
const { buttonMockFactory } = await import('@synerise/ds-mocks');
|
|
93
|
+
return { ...buttonMockFactory() };
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Renders actual button element with:
|
|
97
|
+
// - data-testid (default: 'ds-button' or custom)
|
|
98
|
+
// - data-type, data-mode, data-loading attributes
|
|
99
|
+
// - onClick handler
|
|
100
|
+
// - disabled state
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Minimal Mock Factory
|
|
104
|
+
|
|
105
|
+
Returns `null` - useful when you don't need the component rendered.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
vi.mock('@synerise/ds-button', async () => {
|
|
109
|
+
const { buttonMinimalMockFactory } = await import('@synerise/ds-mocks');
|
|
110
|
+
return { ...buttonMinimalMockFactory() };
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Component renders nothing
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Custom data-testid
|
|
117
|
+
|
|
118
|
+
All mocks support custom `data-testid` via props:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
// In your component:
|
|
122
|
+
<Button data-testid="submit-btn">Submit</Button>
|
|
123
|
+
<Modal data-testid="confirm-modal" open>...</Modal>
|
|
124
|
+
<Icon data-testid="close-icon" icon="CloseM" />
|
|
125
|
+
|
|
126
|
+
// In tests:
|
|
127
|
+
screen.getByTestId('submit-btn')
|
|
128
|
+
screen.getByTestId('confirm-modal')
|
|
129
|
+
screen.getByTestId('close-icon')
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Component-specific Features
|
|
133
|
+
|
|
134
|
+
#### Modal
|
|
135
|
+
|
|
136
|
+
Provides additional test ids for internal elements:
|
|
137
|
+
|
|
138
|
+
- `{testId}-header`
|
|
139
|
+
- `{testId}-title`
|
|
140
|
+
- `{testId}-close`
|
|
141
|
+
- `{testId}-body`
|
|
142
|
+
- `{testId}-footer`
|
|
143
|
+
- `{testId}-ok`
|
|
144
|
+
- `{testId}-cancel`
|
|
145
|
+
|
|
146
|
+
#### Table
|
|
147
|
+
|
|
148
|
+
Provides test ids for rows and cells:
|
|
149
|
+
|
|
150
|
+
- `{testId}-header`
|
|
151
|
+
- `{testId}-row-{index}`
|
|
152
|
+
- `{testId}-cell-{rowIndex}-{colIndex}`
|
|
153
|
+
- `{testId}-checkbox-{index}` (when rowSelection enabled)
|
|
154
|
+
|
|
155
|
+
#### Form
|
|
156
|
+
|
|
157
|
+
Mocks the entire `@synerise/ds-form` package including:
|
|
158
|
+
|
|
159
|
+
- `Form` (default export)
|
|
160
|
+
- `Form.FieldSet`
|
|
161
|
+
- `EditableList`
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
vi.mock('@synerise/ds-form', async () => {
|
|
165
|
+
const { formMockFactory } = await import('@synerise/ds-mocks');
|
|
166
|
+
return { ...formMockFactory() };
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Test ids:
|
|
170
|
+
// - ds-fieldset, ds-fieldset-heading, ds-fieldset-description
|
|
171
|
+
// - ds-editable-list, ds-editable-list-header, ds-editable-list-rows
|
|
172
|
+
// - ds-editable-list-row-{index}, ds-editable-list-delete-{index}, ds-editable-list-add
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### Tooltip
|
|
176
|
+
|
|
177
|
+
Factory accepts options parameter:
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
vi.mock('@synerise/ds-tooltip', async () => {
|
|
181
|
+
const { tooltipMockFactory } = await import('@synerise/ds-mocks');
|
|
182
|
+
return { ...tooltipMockFactory({ showContent: true })() };
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
// Now you can test tooltip content
|
|
186
|
+
screen.getByTestId('ds-tooltip-content');
|
|
187
|
+
screen.getByTestId('ds-tooltip-title');
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### Icon
|
|
191
|
+
|
|
192
|
+
Additional factory for custom render:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
// Standard mock
|
|
196
|
+
vi.mock('@synerise/ds-icon', async () => {
|
|
197
|
+
const { iconMockFactory } = await import('@synerise/ds-mocks');
|
|
198
|
+
return { ...iconMockFactory() };
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// Custom render function
|
|
202
|
+
vi.mock('@synerise/ds-icon', async () => {
|
|
203
|
+
const { iconWithRenderMockFactory } = await import('@synerise/ds-mocks');
|
|
204
|
+
return { ...iconWithRenderMockFactory(({ icon }) => <span>{icon}</span>)() };
|
|
205
|
+
});
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### TypeScript Support
|
|
209
|
+
|
|
210
|
+
All mocks export their prop types:
|
|
211
|
+
|
|
212
|
+
```typescript
|
|
213
|
+
import type {
|
|
214
|
+
MockButtonProps,
|
|
215
|
+
MockIconProps,
|
|
216
|
+
MockModalProps,
|
|
217
|
+
MockTableProps,
|
|
218
|
+
// ... etc
|
|
219
|
+
} from '@synerise/ds-mocks';
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Jest Mocks
|
|
223
|
+
|
|
224
|
+
This package also provides mocks for Jest test framework.
|
|
225
|
+
|
|
226
|
+
### Usage
|
|
227
|
+
|
|
228
|
+
```typescript
|
|
229
|
+
import { jest as dsMocks } from '@synerise/ds-mocks';
|
|
230
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
231
|
+
|
|
232
|
+
describe('MyComponent', () => {
|
|
233
|
+
// Call mocks at the top level of describe block
|
|
234
|
+
dsMocks.mockButton();
|
|
235
|
+
dsMocks.mockModal();
|
|
236
|
+
dsMocks.mockIcon();
|
|
237
|
+
|
|
238
|
+
it('renders button with custom testid', () => {
|
|
239
|
+
render(<MyComponent />);
|
|
240
|
+
|
|
241
|
+
// Default testid
|
|
242
|
+
expect(screen.getByTestId('ds-button')).toBeInTheDocument();
|
|
243
|
+
|
|
244
|
+
// Or custom testid if passed via props
|
|
245
|
+
expect(screen.getByTestId('submit-button')).toBeInTheDocument();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('opens modal on click', () => {
|
|
249
|
+
render(<MyComponent />);
|
|
250
|
+
|
|
251
|
+
fireEvent.click(screen.getByTestId('ds-button'));
|
|
252
|
+
|
|
253
|
+
expect(screen.getByTestId('ds-modal')).toBeInTheDocument();
|
|
254
|
+
expect(screen.getByTestId('ds-modal-title')).toHaveTextContent('My Modal');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Available Jest Mocks
|
|
260
|
+
|
|
261
|
+
| Component | Mock Functions |
|
|
262
|
+
| --------- | --------------------------------------------------- |
|
|
263
|
+
| Button | `mockButton`, `mockButtonMinimal` |
|
|
264
|
+
| Cruds | `mockCruds`, `mockCrudsMinimal` |
|
|
265
|
+
| Dropdown | `mockDropdown`, `mockDropdownMinimal` |
|
|
266
|
+
| Form | `mockForm`, `mockFormMinimal` |
|
|
267
|
+
| Icon | `mockIcon`, `mockIconMinimal`, `mockIconWithRender` |
|
|
268
|
+
| Input | `mockInput`, `mockInputMinimal` |
|
|
269
|
+
| Modal | `mockModal`, `mockModalMinimal` |
|
|
270
|
+
| Select | `mockSelect`, `mockSelectMinimal` |
|
|
271
|
+
| Table | `mockTable`, `mockTableMinimal` |
|
|
272
|
+
| Tabs | `mockTabs`, `mockTabsMinimal` |
|
|
273
|
+
| Tooltip | `mockTooltip`, `mockTooltipMinimal` |
|
|
274
|
+
|
|
275
|
+
### Jest TypeScript Support
|
|
276
|
+
|
|
277
|
+
All Jest mocks export their prop types:
|
|
278
|
+
|
|
279
|
+
```typescript
|
|
280
|
+
import type {
|
|
281
|
+
MockButtonProps,
|
|
282
|
+
MockIconProps,
|
|
283
|
+
MockModalProps,
|
|
284
|
+
MockTableProps,
|
|
285
|
+
// ... etc
|
|
286
|
+
} from '@synerise/ds-mocks/jest';
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## DS Components Coverage
|
|
290
|
+
|
|
291
|
+
### Available Mocks
|
|
292
|
+
|
|
293
|
+
- [x] Button (`@synerise/ds-button`)
|
|
294
|
+
- [x] Cruds (`@synerise/ds-cruds`)
|
|
295
|
+
- [x] Dropdown (`@synerise/ds-dropdown`)
|
|
296
|
+
- [x] Form (`@synerise/ds-form`) - includes Form.FieldSet and EditableList
|
|
297
|
+
- [x] Icon (`@synerise/ds-icon`)
|
|
298
|
+
- [x] Input (`@synerise/ds-input`) - includes TextArea
|
|
299
|
+
- [x] Modal (`@synerise/ds-modal`)
|
|
300
|
+
- [x] Select (`@synerise/ds-select`) - includes Option
|
|
301
|
+
- [x] Table (`@synerise/ds-table`)
|
|
302
|
+
- [x] Tabs (`@synerise/ds-tabs`)
|
|
303
|
+
- [x] Tooltip (`@synerise/ds-tooltip`)
|
|
304
|
+
|
|
305
|
+
### Pending Mocks (TODO)
|
|
306
|
+
|
|
307
|
+
- [ ] ActionArea (`@synerise/ds-action-area`)
|
|
308
|
+
- [ ] Alert (`@synerise/ds-alert`)
|
|
309
|
+
- [ ] AppMenu (`@synerise/ds-app-menu`)
|
|
310
|
+
- [ ] Autocomplete (`@synerise/ds-autocomplete`)
|
|
311
|
+
- [ ] Avatar (`@synerise/ds-avatar`)
|
|
312
|
+
- [ ] AvatarGroup (`@synerise/ds-avatar-group`)
|
|
313
|
+
- [ ] Badge (`@synerise/ds-badge`)
|
|
314
|
+
- [ ] Banner (`@synerise/ds-banner`)
|
|
315
|
+
- [ ] Block (`@synerise/ds-block`)
|
|
316
|
+
- [ ] BroadcastBar (`@synerise/ds-broadcast-bar`)
|
|
317
|
+
- [ ] ButtonGroup (`@synerise/ds-button-group`)
|
|
318
|
+
- [ ] Card (`@synerise/ds-card`)
|
|
319
|
+
- [ ] CardSelect (`@synerise/ds-card-select`)
|
|
320
|
+
- [ ] CardTabs (`@synerise/ds-card-tabs`)
|
|
321
|
+
- [ ] Cascader (`@synerise/ds-cascader`)
|
|
322
|
+
- [ ] Checkbox (`@synerise/ds-checkbox`)
|
|
323
|
+
- [ ] CheckboxTristate (`@synerise/ds-checkbox-tristate`)
|
|
324
|
+
- [ ] CodeArea (`@synerise/ds-code-area`)
|
|
325
|
+
- [ ] CodeSnippet (`@synerise/ds-code-snippet`)
|
|
326
|
+
- [ ] Collector (`@synerise/ds-collector`)
|
|
327
|
+
- [ ] ColorPicker (`@synerise/ds-color-picker`)
|
|
328
|
+
- [ ] ColumnManager (`@synerise/ds-column-manager`)
|
|
329
|
+
- [ ] CompletedWithin (`@synerise/ds-completed-within`)
|
|
330
|
+
- [ ] Condition (`@synerise/ds-condition`)
|
|
331
|
+
- [ ] Confirmation (`@synerise/ds-confirmation`)
|
|
332
|
+
- [ ] ContextSelector (`@synerise/ds-context-selector`)
|
|
333
|
+
- [ ] CopyIcon (`@synerise/ds-copy-icon`)
|
|
334
|
+
- [ ] DataFormat (`@synerise/ds-data-format`)
|
|
335
|
+
- [ ] DatePicker (`@synerise/ds-date-picker`)
|
|
336
|
+
- [ ] DateRangePicker (`@synerise/ds-date-range-picker`)
|
|
337
|
+
- [ ] Description (`@synerise/ds-description`)
|
|
338
|
+
- [ ] Divider (`@synerise/ds-divider`)
|
|
339
|
+
- [ ] Drawer (`@synerise/ds-drawer`)
|
|
340
|
+
- [ ] EditableItemsList (`@synerise/ds-editable-items-list`)
|
|
341
|
+
- [ ] EmojiPicker (`@synerise/ds-emoji-picker`)
|
|
342
|
+
- [ ] EmptyStates (`@synerise/ds-empty-states`)
|
|
343
|
+
- [ ] Estimation (`@synerise/ds-estimation`)
|
|
344
|
+
- [ ] Factors (`@synerise/ds-factors`)
|
|
345
|
+
- [ ] FieldSet (`@synerise/ds-field-set`)
|
|
346
|
+
- [ ] FileUploader (`@synerise/ds-file-uploader`)
|
|
347
|
+
- [ ] Filter (`@synerise/ds-filter`)
|
|
348
|
+
- [ ] Flag (`@synerise/ds-flag`)
|
|
349
|
+
- [ ] FlexBox (`@synerise/ds-flex-box`)
|
|
350
|
+
- [ ] Footer (`@synerise/ds-footer`)
|
|
351
|
+
- [ ] FormField (`@synerise/ds-form-field`)
|
|
352
|
+
- [ ] FormatPicker (`@synerise/ds-format-picker`)
|
|
353
|
+
- [ ] Grid (`@synerise/ds-grid`)
|
|
354
|
+
- [ ] IconPicker (`@synerise/ds-icon-picker`)
|
|
355
|
+
- [ ] InformationCard (`@synerise/ds-information-card`)
|
|
356
|
+
- [ ] InlineAlert (`@synerise/ds-inline-alert`)
|
|
357
|
+
- [ ] InlineEdit (`@synerise/ds-inline-edit`)
|
|
358
|
+
- [ ] InputNumber (`@synerise/ds-input-number`)
|
|
359
|
+
- [ ] Insight (`@synerise/ds-insight`)
|
|
360
|
+
- [ ] ItemFilter (`@synerise/ds-item-filter`)
|
|
361
|
+
- [ ] ItemPicker (`@synerise/ds-item-picker`)
|
|
362
|
+
- [ ] ItemsRoll (`@synerise/ds-items-roll`)
|
|
363
|
+
- [ ] Layout (`@synerise/ds-layout`)
|
|
364
|
+
- [ ] List (`@synerise/ds-list`)
|
|
365
|
+
- [ ] ListItem (`@synerise/ds-list-item`)
|
|
366
|
+
- [ ] Loader (`@synerise/ds-loader`)
|
|
367
|
+
- [ ] Logic (`@synerise/ds-logic`)
|
|
368
|
+
- [ ] ManageableList (`@synerise/ds-manageable-list`)
|
|
369
|
+
- [ ] Mapping (`@synerise/ds-mapping`)
|
|
370
|
+
- [ ] Menu (`@synerise/ds-menu`)
|
|
371
|
+
- [ ] MetricCard (`@synerise/ds-metric-card`)
|
|
372
|
+
- [ ] Navbar (`@synerise/ds-navbar`)
|
|
373
|
+
- [ ] Operators (`@synerise/ds-operators`)
|
|
374
|
+
- [ ] OrderedList (`@synerise/ds-ordered-list`)
|
|
375
|
+
- [ ] PageHeader (`@synerise/ds-page-header`)
|
|
376
|
+
- [ ] Pagination (`@synerise/ds-pagination`)
|
|
377
|
+
- [ ] Panel (`@synerise/ds-panel`)
|
|
378
|
+
- [ ] PanelsResizer (`@synerise/ds-panels-resizer`)
|
|
379
|
+
- [ ] Popconfirm (`@synerise/ds-popconfirm`)
|
|
380
|
+
- [ ] Popover (`@synerise/ds-popover`)
|
|
381
|
+
- [ ] ProgressBar (`@synerise/ds-progress-bar`)
|
|
382
|
+
- [ ] Radio (`@synerise/ds-radio`)
|
|
383
|
+
- [ ] Result (`@synerise/ds-result`)
|
|
384
|
+
- [ ] Scrollbar (`@synerise/ds-scrollbar`)
|
|
385
|
+
- [ ] Search (`@synerise/ds-search`)
|
|
386
|
+
- [ ] SearchBar (`@synerise/ds-search-bar`)
|
|
387
|
+
- [ ] SectionMessage (`@synerise/ds-section-message`)
|
|
388
|
+
- [ ] ShortCuts (`@synerise/ds-short-cuts`)
|
|
389
|
+
- [ ] Sidebar (`@synerise/ds-sidebar`)
|
|
390
|
+
- [ ] SidebarObject (`@synerise/ds-sidebar-object`)
|
|
391
|
+
- [ ] Skeleton (`@synerise/ds-skeleton`)
|
|
392
|
+
- [ ] Slider (`@synerise/ds-slider`)
|
|
393
|
+
- [ ] Sortable (`@synerise/ds-sortable`)
|
|
394
|
+
- [ ] Status (`@synerise/ds-status`)
|
|
395
|
+
- [ ] StepCard (`@synerise/ds-step-card`)
|
|
396
|
+
- [ ] Stepper (`@synerise/ds-stepper`)
|
|
397
|
+
- [ ] Subject (`@synerise/ds-subject`)
|
|
398
|
+
- [ ] SubtleForm (`@synerise/ds-subtle-form`)
|
|
399
|
+
- [ ] Switch (`@synerise/ds-switch`)
|
|
400
|
+
- [ ] Tag (`@synerise/ds-tag`)
|
|
401
|
+
- [ ] Tags (`@synerise/ds-tags`)
|
|
402
|
+
- [ ] TimePicker (`@synerise/ds-time-picker`)
|
|
403
|
+
- [ ] Toast (`@synerise/ds-toast`)
|
|
404
|
+
- [ ] Toolbar (`@synerise/ds-toolbar`)
|
|
405
|
+
- [ ] Tray (`@synerise/ds-tray`)
|
|
406
|
+
- [ ] Typography (`@synerise/ds-typography`)
|
|
407
|
+
- [ ] UnorderedList (`@synerise/ds-unordered-list`)
|
|
408
|
+
- [ ] Wizard (`@synerise/ds-wizard`)
|
|
409
|
+
|
|
410
|
+
## Requirements
|
|
411
|
+
|
|
412
|
+
### Vitest
|
|
413
|
+
|
|
414
|
+
- Vitest with `globals: true` in config
|
|
415
|
+
- React 16.8+ or 17+ or 18+
|
|
416
|
+
- `@testing-library/react` (recommended)
|
|
417
|
+
|
|
418
|
+
### Jest
|
|
419
|
+
|
|
420
|
+
- Jest 27+ or 28+ or 29+
|
|
421
|
+
- React 16.8+ or 17+ or 18+
|
|
422
|
+
- `@testing-library/react` (recommended)
|
|
423
|
+
|
|
424
|
+
## License
|
|
425
|
+
|
|
426
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockButton = function mockButton() {
|
|
3
|
+
jest.mock('@synerise/ds-button', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
onClick = _ref.onClick,
|
|
9
|
+
type = _ref.type,
|
|
10
|
+
mode = _ref.mode,
|
|
11
|
+
disabled = _ref.disabled,
|
|
12
|
+
loading = _ref.loading,
|
|
13
|
+
className = _ref.className,
|
|
14
|
+
dataTestId = _ref['data-testid'];
|
|
15
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
16
|
+
className: "ds-button " + (className || ''),
|
|
17
|
+
"data-testid": dataTestId || 'ds-button',
|
|
18
|
+
"data-type": type,
|
|
19
|
+
"data-mode": mode,
|
|
20
|
+
"data-loading": !!loading,
|
|
21
|
+
onClick: onClick,
|
|
22
|
+
disabled: disabled || !!loading
|
|
23
|
+
}, loading ? 'Loading...' : children);
|
|
24
|
+
})
|
|
25
|
+
};
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export var mockButtonMinimal = function mockButtonMinimal() {
|
|
29
|
+
jest.mock('@synerise/ds-button', function () {
|
|
30
|
+
return {
|
|
31
|
+
__esModule: true,
|
|
32
|
+
"default": jest.fn(function () {
|
|
33
|
+
return null;
|
|
34
|
+
})
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ButtonProps } from '@synerise/ds-button';
|
|
3
|
+
export type MockButtonProps = ButtonProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Button mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { buttonMockFactory } from '@synerise/ds-mocks/Button/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-button', buttonMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const buttonMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ children, onClick, type, mode, disabled, loading, className, "data-testid": dataTestId, }: MockButtonProps) => React.JSX.Element>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Factory function for minimal Button mock.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* vi.mock('@synerise/ds-button', buttonMinimalMockFactory);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const buttonMinimalMockFactory: () => {
|
|
29
|
+
default: import("vitest").Mock<() => null>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Factory function for Button mock.
|
|
4
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { buttonMockFactory } from '@synerise/ds-mocks/Button/vi';
|
|
9
|
+
*
|
|
10
|
+
* vi.mock('@synerise/ds-button', buttonMockFactory);
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export var buttonMockFactory = function buttonMockFactory() {
|
|
14
|
+
return {
|
|
15
|
+
"default": vi.fn(function (_ref) {
|
|
16
|
+
var children = _ref.children,
|
|
17
|
+
onClick = _ref.onClick,
|
|
18
|
+
type = _ref.type,
|
|
19
|
+
mode = _ref.mode,
|
|
20
|
+
disabled = _ref.disabled,
|
|
21
|
+
loading = _ref.loading,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
dataTestId = _ref['data-testid'];
|
|
24
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
25
|
+
className: "ds-button " + (className || ''),
|
|
26
|
+
"data-testid": dataTestId || 'ds-button',
|
|
27
|
+
"data-type": type,
|
|
28
|
+
"data-mode": mode,
|
|
29
|
+
"data-loading": !!loading,
|
|
30
|
+
onClick: onClick,
|
|
31
|
+
disabled: disabled || !!loading
|
|
32
|
+
}, loading ? 'Loading...' : children);
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Factory function for minimal Button mock.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* vi.mock('@synerise/ds-button', buttonMinimalMockFactory);
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export var buttonMinimalMockFactory = function buttonMinimalMockFactory() {
|
|
46
|
+
return {
|
|
47
|
+
"default": vi.fn(function () {
|
|
48
|
+
return null;
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './vi';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var mockCruds = function mockCruds() {
|
|
3
|
+
jest.mock('@synerise/ds-cruds', function () {
|
|
4
|
+
return {
|
|
5
|
+
__esModule: true,
|
|
6
|
+
"default": jest.fn(function (_ref) {
|
|
7
|
+
var onAdd = _ref.onAdd,
|
|
8
|
+
onEdit = _ref.onEdit,
|
|
9
|
+
onDelete = _ref.onDelete,
|
|
10
|
+
onRemove = _ref.onRemove,
|
|
11
|
+
onDuplicate = _ref.onDuplicate,
|
|
12
|
+
onMoveUp = _ref.onMoveUp,
|
|
13
|
+
onMoveDown = _ref.onMoveDown,
|
|
14
|
+
dataTestId = _ref['data-testid'];
|
|
15
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
16
|
+
"data-testid": dataTestId || 'ds-cruds',
|
|
17
|
+
className: "ds-cruds"
|
|
18
|
+
}, onAdd && /*#__PURE__*/React.createElement("button", {
|
|
19
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-add",
|
|
20
|
+
onClick: onAdd
|
|
21
|
+
}, "Add"), onEdit && /*#__PURE__*/React.createElement("button", {
|
|
22
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-edit",
|
|
23
|
+
onClick: onEdit
|
|
24
|
+
}, "Edit"), onDuplicate && /*#__PURE__*/React.createElement("button", {
|
|
25
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-duplicate",
|
|
26
|
+
onClick: onDuplicate
|
|
27
|
+
}, "Duplicate"), onDelete && /*#__PURE__*/React.createElement("button", {
|
|
28
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-delete",
|
|
29
|
+
onClick: onDelete
|
|
30
|
+
}, "Delete"), onRemove && /*#__PURE__*/React.createElement("button", {
|
|
31
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-remove",
|
|
32
|
+
onClick: onRemove
|
|
33
|
+
}, "Remove"), onMoveUp && /*#__PURE__*/React.createElement("button", {
|
|
34
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-move-up",
|
|
35
|
+
onClick: onMoveUp
|
|
36
|
+
}, "Up"), onMoveDown && /*#__PURE__*/React.createElement("button", {
|
|
37
|
+
"data-testid": (dataTestId || 'ds-cruds') + "-move-down",
|
|
38
|
+
onClick: onMoveDown
|
|
39
|
+
}, "Down"));
|
|
40
|
+
})
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
export var mockCrudsMinimal = function mockCrudsMinimal() {
|
|
45
|
+
jest.mock('@synerise/ds-cruds', function () {
|
|
46
|
+
return {
|
|
47
|
+
__esModule: true,
|
|
48
|
+
"default": jest.fn(function () {
|
|
49
|
+
return null;
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CrudsProps } from '@synerise/ds-cruds/dist/Cruds.types';
|
|
3
|
+
export type MockCrudsProps = CrudsProps & {
|
|
4
|
+
'data-testid'?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Factory function for Cruds mock.
|
|
8
|
+
* Use directly with vi.mock() to avoid hoisting issues.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { crudsMockFactory } from '@synerise/ds-mocks/Cruds/vi';
|
|
13
|
+
*
|
|
14
|
+
* vi.mock('@synerise/ds-cruds', crudsMockFactory);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const crudsMockFactory: () => {
|
|
18
|
+
default: import("vitest").Mock<({ onAdd, onEdit, onDelete, onRemove, onDuplicate, onMoveUp, onMoveDown, "data-testid": dataTestId, }: MockCrudsProps) => React.JSX.Element>;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Factory function for minimal Cruds mock.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* vi.mock('@synerise/ds-cruds', crudsMinimalMockFactory);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const crudsMinimalMockFactory: () => {
|
|
29
|
+
default: import("vitest").Mock<() => null>;
|
|
30
|
+
};
|