@talixo-ds/options-input 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/min-max-value-label.d.ts +3 -2
- package/dist/components/min-max-value-label.js +2 -2
- package/dist/components/min-max-value-label.js.map +1 -1
- package/dist/components/options-input-content-item.d.ts +2 -2
- package/dist/components/options-input-content-item.js +10 -10
- package/dist/components/options-input-content-item.js.map +1 -1
- package/dist/components/options-input-dropdown-item.d.ts +4 -3
- package/dist/components/options-input-dropdown-item.js +31 -31
- package/dist/components/options-input-dropdown-item.js.map +1 -1
- package/dist/options-input.d.ts +9 -9
- package/dist/options-input.js +44 -47
- package/dist/options-input.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +2 -0
- package/dist/utils.js.map +1 -0
- package/package.json +4 -4
- package/src/__tests__/options-input.spec.tsx +147 -0
- package/src/__tests__/utils.spec.ts +12 -0
- package/src/components/__tests__/min-max-value-label.spec.tsx +19 -19
- package/src/components/__tests__/options-input-content-item.spec.tsx +52 -60
- package/src/components/__tests__/options-input-dropdown-item.spec.tsx +74 -85
- package/src/components/min-max-value-label.tsx +10 -15
- package/src/components/options-input-content-item.tsx +47 -54
- package/src/components/options-input-dropdown-item.tsx +133 -138
- package/src/options-input.tsx +247 -251
- package/src/utils.ts +1 -0
- package/tsconfig.build.json +8 -0
- package/__tests__/__snapshots__/options-input.spec.tsx.snap +0 -119
- package/__tests__/options-input.spec.tsx +0 -242
- package/dist/components/__tests__/min-max-value-label.spec.d.ts +0 -1
- package/dist/components/__tests__/min-max-value-label.spec.js +0 -21
- package/dist/components/__tests__/min-max-value-label.spec.js.map +0 -1
- package/dist/components/__tests__/options-input-content-item.spec.d.ts +0 -1
- package/dist/components/__tests__/options-input-content-item.spec.js +0 -49
- package/dist/components/__tests__/options-input-content-item.spec.js.map +0 -1
- package/dist/components/__tests__/options-input-dropdown-item.spec.d.ts +0 -1
- package/dist/components/__tests__/options-input-dropdown-item.spec.js +0 -67
- package/dist/components/__tests__/options-input-dropdown-item.spec.js.map +0 -1
- package/src/components/__tests__/__snapshots__/min-max-value-label.spec.tsx.snap +0 -17
- package/src/components/__tests__/__snapshots__/options-input-content-item.spec.tsx.snap +0 -138
- package/src/components/__tests__/__snapshots__/options-input-dropdown-item.spec.tsx.snap +0 -134
- package/tsconfig.json +0 -8
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ShallowRenderer from 'react-test-renderer/shallow';
|
|
3
|
-
import {
|
|
4
|
-
render,
|
|
5
|
-
screen,
|
|
6
|
-
fireEvent,
|
|
7
|
-
waitFor,
|
|
8
|
-
act,
|
|
9
|
-
} from '@testing-library/react';
|
|
10
|
-
import { vi } from 'vitest';
|
|
11
|
-
import type { Mock } from 'vitest';
|
|
12
|
-
import { OptionsInput } from '../src/options-input';
|
|
13
|
-
import '@testing-library/jest-dom';
|
|
14
|
-
|
|
15
|
-
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
16
|
-
return {
|
|
17
|
-
...await importOriginal<typeof import('@mui/icons-material')>(),
|
|
18
|
-
luggage: 'div',
|
|
19
|
-
dog: 'div',
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
vi.mock('@talixo-ds/icons', async (importOriginal) => {
|
|
24
|
-
return {
|
|
25
|
-
...await importOriginal<typeof import('@talixo-ds/icons')>(),
|
|
26
|
-
football: 'div',
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
vi.mock("react", async (importOriginal) => {
|
|
31
|
-
const actual = await importOriginal()
|
|
32
|
-
return {
|
|
33
|
-
...actual as any,
|
|
34
|
-
useState: () => [[], () => null],
|
|
35
|
-
useEffect: () => vi.fn()
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
const props = {
|
|
40
|
-
options: [
|
|
41
|
-
{
|
|
42
|
-
id: 'luggage',
|
|
43
|
-
icon: 'luggage',
|
|
44
|
-
label: 'luggage',
|
|
45
|
-
details: 'This is your luggage',
|
|
46
|
-
min: 0,
|
|
47
|
-
max: 9,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
id: 'dog',
|
|
51
|
-
icon: 'this icon does not exist',
|
|
52
|
-
label: 'dog',
|
|
53
|
-
min: 0,
|
|
54
|
-
max: 3,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 'sport-equipment',
|
|
58
|
-
icon: 'football',
|
|
59
|
-
label: 'sport equipment',
|
|
60
|
-
min: 0,
|
|
61
|
-
max: 1,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
id: 'test-id',
|
|
65
|
-
defaultValue: { luggage: 2, 'sport-equipment': 5 },
|
|
66
|
-
persistentOptions: ['sport-equipment'],
|
|
67
|
-
className: 'test-class',
|
|
68
|
-
onChange: vi.fn(),
|
|
69
|
-
onFocus: vi.fn(),
|
|
70
|
-
onBlur: vi.fn(),
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const mockOptions = props.options.map((option) => ({
|
|
74
|
-
...option,
|
|
75
|
-
quantity: 1,
|
|
76
|
-
inputQuantity: 1,
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
// FIXME: GET RID OF SKIP
|
|
80
|
-
describe.skip('OptionsInput', () => {
|
|
81
|
-
describe('snapshots', () => {
|
|
82
|
-
let component: JSX.Element;
|
|
83
|
-
const shallowRenderer = ShallowRenderer.createRenderer();
|
|
84
|
-
|
|
85
|
-
beforeEach(() => {
|
|
86
|
-
// (useState as Mock).mockImplementationOnce(() => [
|
|
87
|
-
// mockOptions,
|
|
88
|
-
// vi.fn(),
|
|
89
|
-
// ]);
|
|
90
|
-
|
|
91
|
-
// (useState as Mock).mockImplementationOnce((vi.importActual('react') as any).useState);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should match snapshot', () => {
|
|
95
|
-
shallowRenderer.render(<OptionsInput {...props} />);
|
|
96
|
-
component = shallowRenderer.getRenderOutput();
|
|
97
|
-
|
|
98
|
-
expect(component).toMatchSnapshot();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('should render disabled input properly', () => {
|
|
102
|
-
shallowRenderer.render(<OptionsInput {...props} disabled />);
|
|
103
|
-
component = shallowRenderer.getRenderOutput();
|
|
104
|
-
|
|
105
|
-
expect(component).toMatchSnapshot();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
describe('events', () => {
|
|
110
|
-
beforeAll(() => {
|
|
111
|
-
// (useState as Mock).mockImplementationOnce((vi.importActual('react') as any).useState);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should open input dropdown properly', async () => {
|
|
115
|
-
const { getAllByTestId } = render(<OptionsInput {...props} />);
|
|
116
|
-
const optionsInputContainer = getAllByTestId(
|
|
117
|
-
'options-input-container'
|
|
118
|
-
)[0];
|
|
119
|
-
|
|
120
|
-
act(() => {
|
|
121
|
-
fireEvent.click(optionsInputContainer);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
await waitFor(() => {
|
|
125
|
-
expect(
|
|
126
|
-
screen.queryByTestId('options-dropdown-list')
|
|
127
|
-
).toBeInTheDocument();
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('should not open dropdown when input is disabled', async () => {
|
|
132
|
-
const { getAllByTestId } = render(<OptionsInput {...props} disabled />);
|
|
133
|
-
|
|
134
|
-
const optionsInputContainer = getAllByTestId(
|
|
135
|
-
'options-input-container'
|
|
136
|
-
)[0];
|
|
137
|
-
|
|
138
|
-
act(() => {
|
|
139
|
-
fireEvent.click(optionsInputContainer);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
await waitFor(() => {
|
|
143
|
-
expect(
|
|
144
|
-
screen.queryByTestId('options-dropdown-list')
|
|
145
|
-
).not.toBeInTheDocument();
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('should handle input focus properly', () => {
|
|
150
|
-
const { getAllByTestId } = render(<OptionsInput {...props} />);
|
|
151
|
-
|
|
152
|
-
const optionsInputContainer = getAllByTestId(
|
|
153
|
-
'options-input-container'
|
|
154
|
-
)[0];
|
|
155
|
-
|
|
156
|
-
act(() => {
|
|
157
|
-
fireEvent.focus(optionsInputContainer);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
expect(props.onFocus).toHaveBeenCalledWith({
|
|
161
|
-
dog: 0,
|
|
162
|
-
luggage: 2,
|
|
163
|
-
'sport-equipment': 1,
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('should handle input blur properly', () => {
|
|
168
|
-
const { getAllByTestId } = render(<OptionsInput {...props} />);
|
|
169
|
-
|
|
170
|
-
const optionsInputContainer = getAllByTestId(
|
|
171
|
-
'options-input-container'
|
|
172
|
-
)[0];
|
|
173
|
-
|
|
174
|
-
act(() => {
|
|
175
|
-
fireEvent.blur(optionsInputContainer);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
expect(props.onBlur).toHaveBeenCalledWith({
|
|
179
|
-
dog: 0,
|
|
180
|
-
luggage: 2,
|
|
181
|
-
'sport-equipment': 1,
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('should handle input option change properly', async () => {
|
|
186
|
-
const { getAllByTestId } = render(<OptionsInput {...props} />);
|
|
187
|
-
|
|
188
|
-
const optionsInputContainer = getAllByTestId(
|
|
189
|
-
'options-input-container'
|
|
190
|
-
)[0];
|
|
191
|
-
|
|
192
|
-
act(() => {
|
|
193
|
-
fireEvent.click(optionsInputContainer);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
await waitFor(() => {
|
|
197
|
-
const optionCountInput = screen.getAllByTestId(
|
|
198
|
-
'dropdown-item-input'
|
|
199
|
-
)[0];
|
|
200
|
-
|
|
201
|
-
act(() => {
|
|
202
|
-
fireEvent.change(optionCountInput, { target: { value: 9 } });
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
expect(props.onChange).toHaveBeenCalledWith({
|
|
206
|
-
dog: 0,
|
|
207
|
-
luggage: 9,
|
|
208
|
-
'sport-equipment': 1,
|
|
209
|
-
});
|
|
210
|
-
expect(screen.getAllByTestId('option-item')[0]).toHaveTextContent('9');
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
it('should handle input option blur properly', async () => {
|
|
215
|
-
const { getAllByTestId } = render(<OptionsInput {...props} />);
|
|
216
|
-
|
|
217
|
-
const optionsInputContainer = getAllByTestId(
|
|
218
|
-
'options-input-container'
|
|
219
|
-
)[0];
|
|
220
|
-
|
|
221
|
-
fireEvent.click(optionsInputContainer);
|
|
222
|
-
|
|
223
|
-
await waitFor(() => {
|
|
224
|
-
const optionCountInput = screen.getAllByTestId(
|
|
225
|
-
'dropdown-item-input'
|
|
226
|
-
)[0];
|
|
227
|
-
|
|
228
|
-
act(() => {
|
|
229
|
-
fireEvent.change(optionCountInput, { target: { value: 500 } });
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
expect(optionCountInput).toHaveAttribute('value', '500');
|
|
233
|
-
|
|
234
|
-
act(() => {
|
|
235
|
-
fireEvent.blur(optionCountInput);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
expect(optionCountInput).toHaveAttribute('value', '9');
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import ShallowRenderer from 'react-test-renderer/shallow';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import { MinMaxValueLabel } from '../min-max-value-label';
|
|
5
|
-
const props = {
|
|
6
|
-
min: 0,
|
|
7
|
-
max: 100,
|
|
8
|
-
color: 'black',
|
|
9
|
-
};
|
|
10
|
-
describe('MinMaxValueLabel', () => {
|
|
11
|
-
let component;
|
|
12
|
-
const renderer = ShallowRenderer.createRenderer();
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
renderer.render(_jsx(MinMaxValueLabel, { ...props }));
|
|
15
|
-
component = renderer.getRenderOutput();
|
|
16
|
-
});
|
|
17
|
-
it('should match snapshot', () => {
|
|
18
|
-
expect(component).toMatchSnapshot();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=min-max-value-label.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"min-max-value-label.spec.js","sourceRoot":"","sources":["../../../src/components/__tests__/min-max-value-label.spec.tsx"],"names":[],"mappings":";AACA,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,KAAK,GAAG;IACZ,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,OAAO;CACf,CAAC;AAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,IAAI,SAAsB,CAAC;IAC3B,MAAM,QAAQ,GAAG,eAAe,CAAC,cAAc,EAAE,CAAC;IAElD,UAAU,CAAC,GAAG,EAAE;QACd,QAAQ,CAAC,MAAM,CAAC,KAAC,gBAAgB,OAAK,KAAK,GAAI,CAAC,CAAC;QACjD,SAAS,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import ShallowRenderer from 'react-test-renderer/shallow';
|
|
3
|
-
import OptionsInputContentItem from '../options-input-content-item';
|
|
4
|
-
import { vi } from 'vitest';
|
|
5
|
-
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
6
|
-
return {
|
|
7
|
-
...await importOriginal(),
|
|
8
|
-
luggage: 'div',
|
|
9
|
-
};
|
|
10
|
-
});
|
|
11
|
-
vi.mock('@talixo-ds/icons', async (importOriginal) => {
|
|
12
|
-
return {
|
|
13
|
-
...await importOriginal(),
|
|
14
|
-
football: 'div',
|
|
15
|
-
};
|
|
16
|
-
});
|
|
17
|
-
const props = {
|
|
18
|
-
item: {
|
|
19
|
-
id: 'luggage',
|
|
20
|
-
icon: 'luggage',
|
|
21
|
-
label: 'luggage',
|
|
22
|
-
details: 'This is your luggage',
|
|
23
|
-
min: -10,
|
|
24
|
-
max: 10,
|
|
25
|
-
quantity: 0,
|
|
26
|
-
inputQuantity: 0,
|
|
27
|
-
},
|
|
28
|
-
displayMinMax: true,
|
|
29
|
-
};
|
|
30
|
-
describe('OptionsInputDropdownItem', () => {
|
|
31
|
-
let component;
|
|
32
|
-
const renderer = ShallowRenderer.createRenderer();
|
|
33
|
-
it('should match snapshot', () => {
|
|
34
|
-
renderer.render(_jsx(OptionsInputContentItem, { ...props }));
|
|
35
|
-
component = renderer.getRenderOutput();
|
|
36
|
-
expect(component).toMatchSnapshot();
|
|
37
|
-
});
|
|
38
|
-
it('should render proper alternative styling', () => {
|
|
39
|
-
renderer.render(_jsx(OptionsInputContentItem, { item: { ...props.item, quantity: 1 } }));
|
|
40
|
-
component = renderer.getRenderOutput();
|
|
41
|
-
expect(component).toMatchSnapshot();
|
|
42
|
-
});
|
|
43
|
-
it('should not render tooltip when there is no label', () => {
|
|
44
|
-
renderer.render(_jsx(OptionsInputContentItem, { item: { ...props.item, label: undefined } }));
|
|
45
|
-
component = renderer.getRenderOutput();
|
|
46
|
-
expect(component).toMatchSnapshot();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
//# sourceMappingURL=options-input-content-item.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options-input-content-item.spec.js","sourceRoot":"","sources":["../../../src/components/__tests__/options-input-content-item.spec.tsx"],"names":[],"mappings":";AACA,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,uBAAuB,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG5B,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACtD,OAAO;QACL,GAAG,MAAM,cAAc,EAAwC;QAC/D,OAAO,EAAE,KAAK;KACf,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACnD,OAAO;QACL,GAAG,MAAM,cAAc,EAAqC;QAC5D,QAAQ,EAAE,KAAK;KAChB,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE;QACJ,EAAE,EAAE,SAAS;QACb,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,sBAAsB;QAC/B,GAAG,EAAE,CAAC,EAAE;QACR,GAAG,EAAE,EAAE;QACP,QAAQ,EAAE,CAAC;QACX,aAAa,EAAE,CAAC;KACjB;IACD,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,SAAsB,CAAC;IAC3B,MAAM,QAAQ,GAAG,eAAe,CAAC,cAAc,EAAE,CAAC;IAElD,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,QAAQ,CAAC,MAAM,CAAC,KAAC,uBAAuB,OAAK,KAAK,GAAI,CAAC,CAAC;QAExD,SAAS,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;QACvC,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,QAAQ,CAAC,MAAM,CACb,KAAC,uBAAuB,IAAC,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,EAAE,GAAI,CAClE,CAAC;QAEF,SAAS,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;QACvC,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,QAAQ,CAAC,MAAM,CACb,KAAC,uBAAuB,IAAC,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAI,CACvE,CAAC;QAEF,SAAS,GAAG,QAAQ,CAAC,eAAe,EAAE,CAAC;QACvC,MAAM,CAAC,SAAS,CAAC,CAAC,eAAe,EAAE,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import ShallowRenderer from 'react-test-renderer/shallow';
|
|
3
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
4
|
-
import { vi } from 'vitest';
|
|
5
|
-
import OptionsInputDropdownItem from '../options-input-dropdown-item';
|
|
6
|
-
vi.mock('@mui/icons-material', async (importOriginal) => {
|
|
7
|
-
return {
|
|
8
|
-
...await importOriginal(),
|
|
9
|
-
luggage: 'div',
|
|
10
|
-
};
|
|
11
|
-
});
|
|
12
|
-
vi.mock('@talixo-ds/icons', async (importOriginal) => {
|
|
13
|
-
return {
|
|
14
|
-
...await importOriginal(),
|
|
15
|
-
football: 'div',
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
const onChangeMock = vi.fn();
|
|
19
|
-
const onBlurMock = vi.fn();
|
|
20
|
-
const props = {
|
|
21
|
-
item: {
|
|
22
|
-
id: 'luggage-id',
|
|
23
|
-
icon: 'luggage',
|
|
24
|
-
details: 'This is your luggage. Please, keep your attention not to lose it.',
|
|
25
|
-
min: -10,
|
|
26
|
-
max: 10,
|
|
27
|
-
quantity: 0,
|
|
28
|
-
inputQuantity: 0,
|
|
29
|
-
},
|
|
30
|
-
onBlur: onBlurMock,
|
|
31
|
-
onChange: onChangeMock,
|
|
32
|
-
index: 1,
|
|
33
|
-
};
|
|
34
|
-
describe('OptionsInputDropdownItem', () => {
|
|
35
|
-
let component;
|
|
36
|
-
const renderer = ShallowRenderer.createRenderer();
|
|
37
|
-
it('should match snapshot', () => {
|
|
38
|
-
renderer.render(_jsx(OptionsInputDropdownItem, { ...props }));
|
|
39
|
-
component = renderer.getRenderOutput();
|
|
40
|
-
expect(component).toMatchSnapshot();
|
|
41
|
-
});
|
|
42
|
-
describe('events', () => {
|
|
43
|
-
beforeEach(() => render(_jsx(OptionsInputDropdownItem, { ...props })));
|
|
44
|
-
it('should call onChange on text field edit', async () => {
|
|
45
|
-
const input = screen.getByTestId('dropdown-item-input');
|
|
46
|
-
await fireEvent.change(input, { target: { value: '10' } });
|
|
47
|
-
expect(onChangeMock).toHaveBeenCalledWith('luggage-id', '10');
|
|
48
|
-
});
|
|
49
|
-
it('should call onChange on increment button click', () => {
|
|
50
|
-
const buttons = screen.getAllByRole('button');
|
|
51
|
-
fireEvent.click(buttons[0]);
|
|
52
|
-
expect(onChangeMock).toHaveBeenCalledWith('luggage-id', 1);
|
|
53
|
-
});
|
|
54
|
-
it('should call onChange on decrement button click', () => {
|
|
55
|
-
const buttons = screen.getAllByRole('button');
|
|
56
|
-
fireEvent.click(buttons[1]);
|
|
57
|
-
expect(onChangeMock).toHaveBeenCalledWith('luggage-id', -1);
|
|
58
|
-
});
|
|
59
|
-
it('should expand details content', () => {
|
|
60
|
-
expect(screen.getByTestId('option-details')).toHaveTextContent(props.item.details.slice(0, 15));
|
|
61
|
-
const optionDetailsContainer = screen.getByTestId('option-details-container');
|
|
62
|
-
fireEvent.mouseEnter(optionDetailsContainer);
|
|
63
|
-
expect(screen.getByTestId('option-details')).toHaveTextContent(props.item.details);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
//# sourceMappingURL=options-input-dropdown-item.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options-input-dropdown-item.spec.js","sourceRoot":"","sources":["../../../src/components/__tests__/options-input-dropdown-item.spec.tsx"],"names":[],"mappings":";AACA,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,wBAAwB,MAAM,gCAAgC,CAAC;AAGtE,EAAE,CAAC,IAAI,CAAC,qBAAqB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACtD,OAAO;QACL,GAAG,MAAM,cAAc,EAAwC;QAC/D,OAAO,EAAE,KAAK;KACf,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACnD,OAAO;QACL,GAAG,MAAM,cAAc,EAAqC;QAC5D,QAAQ,EAAE,KAAK;KAChB,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,MAAM,YAAY,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;AAC7B,MAAM,UAAU,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;AAE3B,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE;QACJ,EAAE,EAAE,YAAY;QAChB,IAAI,EAA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
|
-
variant="caption"
|
|
12
|
-
>
|
|
13
|
-
min: 0
|
|
14
|
-
,
|
|
15
|
-
max: 100
|
|
16
|
-
</ForwardRef(Typography)>
|
|
17
|
-
`;
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`OptionsInputDropdownItem > should match snapshot 1`] = `
|
|
4
|
-
<ForwardRef(Box)
|
|
5
|
-
alignItems="center"
|
|
6
|
-
color="#a4a5b2"
|
|
7
|
-
data-testid="option-item"
|
|
8
|
-
display="flex"
|
|
9
|
-
gap={0.5}
|
|
10
|
-
>
|
|
11
|
-
<ForwardRef(Tooltip)
|
|
12
|
-
arrow={true}
|
|
13
|
-
placement="top"
|
|
14
|
-
title={
|
|
15
|
-
<ForwardRef(Box)
|
|
16
|
-
display="flex"
|
|
17
|
-
flexDirection="column"
|
|
18
|
-
>
|
|
19
|
-
<ForwardRef(Typography)
|
|
20
|
-
fontWeight={600}
|
|
21
|
-
sx={
|
|
22
|
-
{
|
|
23
|
-
"my": 0,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
variant="caption"
|
|
27
|
-
>
|
|
28
|
-
luggage
|
|
29
|
-
</ForwardRef(Typography)>
|
|
30
|
-
<ForwardRef(Typography)
|
|
31
|
-
sx={
|
|
32
|
-
{
|
|
33
|
-
"my": 0,
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
variant="caption"
|
|
37
|
-
>
|
|
38
|
-
This is your luggage
|
|
39
|
-
</ForwardRef(Typography)>
|
|
40
|
-
<MinMaxValueLabel
|
|
41
|
-
max={10}
|
|
42
|
-
min={-10}
|
|
43
|
-
/>
|
|
44
|
-
</ForwardRef(Box)>
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
<span>
|
|
48
|
-
<div
|
|
49
|
-
color="#a4a5b2"
|
|
50
|
-
fontSize="medium"
|
|
51
|
-
/>
|
|
52
|
-
</span>
|
|
53
|
-
</ForwardRef(Tooltip)>
|
|
54
|
-
<ForwardRef(Typography)
|
|
55
|
-
color="#a4a5b2"
|
|
56
|
-
variant="h6"
|
|
57
|
-
>
|
|
58
|
-
0
|
|
59
|
-
</ForwardRef(Typography)>
|
|
60
|
-
</ForwardRef(Box)>
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
exports[`OptionsInputDropdownItem > should not render tooltip when there is no label 1`] = `
|
|
64
|
-
<ForwardRef(Box)
|
|
65
|
-
alignItems="center"
|
|
66
|
-
color="#a4a5b2"
|
|
67
|
-
data-testid="option-item"
|
|
68
|
-
display="flex"
|
|
69
|
-
gap={0.5}
|
|
70
|
-
>
|
|
71
|
-
<div
|
|
72
|
-
color="#a4a5b2"
|
|
73
|
-
fontSize="medium"
|
|
74
|
-
/>
|
|
75
|
-
<ForwardRef(Typography)
|
|
76
|
-
color="#a4a5b2"
|
|
77
|
-
variant="h6"
|
|
78
|
-
>
|
|
79
|
-
0
|
|
80
|
-
</ForwardRef(Typography)>
|
|
81
|
-
</ForwardRef(Box)>
|
|
82
|
-
`;
|
|
83
|
-
|
|
84
|
-
exports[`OptionsInputDropdownItem > should render proper alternative styling 1`] = `
|
|
85
|
-
<ForwardRef(Box)
|
|
86
|
-
alignItems="center"
|
|
87
|
-
color="#000000"
|
|
88
|
-
data-testid="option-item"
|
|
89
|
-
display="flex"
|
|
90
|
-
gap={0.5}
|
|
91
|
-
>
|
|
92
|
-
<ForwardRef(Tooltip)
|
|
93
|
-
arrow={true}
|
|
94
|
-
placement="top"
|
|
95
|
-
title={
|
|
96
|
-
<ForwardRef(Box)
|
|
97
|
-
display="flex"
|
|
98
|
-
flexDirection="column"
|
|
99
|
-
>
|
|
100
|
-
<ForwardRef(Typography)
|
|
101
|
-
fontWeight={600}
|
|
102
|
-
sx={
|
|
103
|
-
{
|
|
104
|
-
"my": 0,
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
variant="caption"
|
|
108
|
-
>
|
|
109
|
-
luggage
|
|
110
|
-
</ForwardRef(Typography)>
|
|
111
|
-
<ForwardRef(Typography)
|
|
112
|
-
sx={
|
|
113
|
-
{
|
|
114
|
-
"my": 0,
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
variant="caption"
|
|
118
|
-
>
|
|
119
|
-
This is your luggage
|
|
120
|
-
</ForwardRef(Typography)>
|
|
121
|
-
</ForwardRef(Box)>
|
|
122
|
-
}
|
|
123
|
-
>
|
|
124
|
-
<span>
|
|
125
|
-
<div
|
|
126
|
-
color="#000000"
|
|
127
|
-
fontSize="medium"
|
|
128
|
-
/>
|
|
129
|
-
</span>
|
|
130
|
-
</ForwardRef(Tooltip)>
|
|
131
|
-
<ForwardRef(Typography)
|
|
132
|
-
color="#000000"
|
|
133
|
-
variant="h6"
|
|
134
|
-
>
|
|
135
|
-
1
|
|
136
|
-
</ForwardRef(Typography)>
|
|
137
|
-
</ForwardRef(Box)>
|
|
138
|
-
`;
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
-
|
|
3
|
-
exports[`OptionsInputDropdownItem > should match snapshot 1`] = `
|
|
4
|
-
<React.Fragment>
|
|
5
|
-
<ForwardRef(Divider)
|
|
6
|
-
sx={
|
|
7
|
-
{
|
|
8
|
-
"color": [Function],
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/>
|
|
12
|
-
<ForwardRef(ListItem)
|
|
13
|
-
className="options-input__dropdown-item options-input__dropdown-item--empty"
|
|
14
|
-
sx={
|
|
15
|
-
{
|
|
16
|
-
"display": "flex",
|
|
17
|
-
"justifyContent": "space-between",
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
>
|
|
21
|
-
<ForwardRef(Box)
|
|
22
|
-
alignItems="center"
|
|
23
|
-
display="flex"
|
|
24
|
-
>
|
|
25
|
-
<div
|
|
26
|
-
color="black"
|
|
27
|
-
fontSize="small"
|
|
28
|
-
/>
|
|
29
|
-
<ForwardRef(TextField)
|
|
30
|
-
InputProps={
|
|
31
|
-
{
|
|
32
|
-
"disableUnderline": true,
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
className="options-input__dropdown-item-input"
|
|
36
|
-
inputProps={
|
|
37
|
-
{
|
|
38
|
-
"data-testid": "dropdown-item-input",
|
|
39
|
-
"inputMode": "numeric",
|
|
40
|
-
"pattern": "-?[0-9]*",
|
|
41
|
-
"style": {
|
|
42
|
-
"textAlign": "center",
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
onBlur={[MockFunction spy]}
|
|
47
|
-
onChange={[Function]}
|
|
48
|
-
value={0}
|
|
49
|
-
variant="standard"
|
|
50
|
-
/>
|
|
51
|
-
<ForwardRef(Box)
|
|
52
|
-
display="flex"
|
|
53
|
-
flexDirection="column"
|
|
54
|
-
justifyContent="center"
|
|
55
|
-
minWidth="5rem"
|
|
56
|
-
paddingLeft={1}
|
|
57
|
-
paddingRight={2}
|
|
58
|
-
>
|
|
59
|
-
<ForwardRef(Typography)
|
|
60
|
-
color="black"
|
|
61
|
-
fontSize={13}
|
|
62
|
-
fontWeight={600}
|
|
63
|
-
sx={
|
|
64
|
-
{
|
|
65
|
-
"my": 0,
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
variant="caption"
|
|
69
|
-
>
|
|
70
|
-
luggage-id
|
|
71
|
-
</ForwardRef(Typography)>
|
|
72
|
-
<ForwardRef(Box)
|
|
73
|
-
data-testid="option-details-container"
|
|
74
|
-
height="1rem"
|
|
75
|
-
onMouseEnter={[Function]}
|
|
76
|
-
onMouseLeave={[Function]}
|
|
77
|
-
position="relative"
|
|
78
|
-
>
|
|
79
|
-
<ForwardRef(Typography)
|
|
80
|
-
color="gray"
|
|
81
|
-
data-testid="option-details"
|
|
82
|
-
sx={
|
|
83
|
-
{
|
|
84
|
-
"my": 0,
|
|
85
|
-
"position": "fixed",
|
|
86
|
-
"zIndex": 10000,
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
variant="caption"
|
|
90
|
-
>
|
|
91
|
-
This is your lu...
|
|
92
|
-
</ForwardRef(Typography)>
|
|
93
|
-
</ForwardRef(Box)>
|
|
94
|
-
</ForwardRef(Box)>
|
|
95
|
-
</ForwardRef(Box)>
|
|
96
|
-
<ForwardRef(ButtonGroup)
|
|
97
|
-
className="options-input__dropdown-item-buttons"
|
|
98
|
-
size="small"
|
|
99
|
-
variant="outlined"
|
|
100
|
-
>
|
|
101
|
-
<ForwardRef(Button)
|
|
102
|
-
className="options-input__dropdown-item-button"
|
|
103
|
-
color="primary"
|
|
104
|
-
disabled={false}
|
|
105
|
-
onClick={[Function]}
|
|
106
|
-
role="button"
|
|
107
|
-
>
|
|
108
|
-
<Memo
|
|
109
|
-
sx={
|
|
110
|
-
{
|
|
111
|
-
"color": "primary",
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/>
|
|
115
|
-
</ForwardRef(Button)>
|
|
116
|
-
<ForwardRef(Button)
|
|
117
|
-
className="options-input__dropdown-item-button"
|
|
118
|
-
color="primary"
|
|
119
|
-
disabled={false}
|
|
120
|
-
onClick={[Function]}
|
|
121
|
-
role="button"
|
|
122
|
-
>
|
|
123
|
-
<Memo
|
|
124
|
-
sx={
|
|
125
|
-
{
|
|
126
|
-
"color": "primary",
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/>
|
|
130
|
-
</ForwardRef(Button)>
|
|
131
|
-
</ForwardRef(ButtonGroup)>
|
|
132
|
-
</ForwardRef(ListItem)>
|
|
133
|
-
</React.Fragment>
|
|
134
|
-
`;
|