@salutejs/sdds-api-tests 0.6.0-canary.2759.25731439518.0 → 0.6.0-dev.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salutejs/sdds-api-tests",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-dev.0",
|
|
4
4
|
"description": "API tests for components",
|
|
5
5
|
"author": "Salute Frontend Team <salute.developers@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,19 +13,19 @@
|
|
|
13
13
|
"test": "rm -rf tests && node script.mjs && vitest run --config ./vitest.config.ts"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@salutejs/plasma-b2c": "1.617.0-
|
|
17
|
-
"@salutejs/plasma-giga": "0.344.0-
|
|
18
|
-
"@salutejs/plasma-icons": "1.237.0-
|
|
19
|
-
"@salutejs/plasma-web": "1.619.0-
|
|
20
|
-
"@salutejs/sdds-bizcom": "0.349.0-
|
|
21
|
-
"@salutejs/sdds-cs": "0.353.0-
|
|
22
|
-
"@salutejs/sdds-dfa": "0.347.0-
|
|
23
|
-
"@salutejs/sdds-finai": "0.340.0-
|
|
24
|
-
"@salutejs/sdds-insol": "0.344.0-
|
|
25
|
-
"@salutejs/sdds-netology": "0.348.0-
|
|
26
|
-
"@salutejs/sdds-platform-ai": "0.348.0-
|
|
27
|
-
"@salutejs/sdds-scan": "0.347.0-
|
|
28
|
-
"@salutejs/sdds-serv": "0.348.0-
|
|
16
|
+
"@salutejs/plasma-b2c": "1.617.0-dev.0",
|
|
17
|
+
"@salutejs/plasma-giga": "0.344.0-dev.0",
|
|
18
|
+
"@salutejs/plasma-icons": "1.237.0-dev.0",
|
|
19
|
+
"@salutejs/plasma-web": "1.619.0-dev.0",
|
|
20
|
+
"@salutejs/sdds-bizcom": "0.349.0-dev.0",
|
|
21
|
+
"@salutejs/sdds-cs": "0.353.0-dev.0",
|
|
22
|
+
"@salutejs/sdds-dfa": "0.347.0-dev.0",
|
|
23
|
+
"@salutejs/sdds-finai": "0.340.0-dev.0",
|
|
24
|
+
"@salutejs/sdds-insol": "0.344.0-dev.0",
|
|
25
|
+
"@salutejs/sdds-netology": "0.348.0-dev.0",
|
|
26
|
+
"@salutejs/sdds-platform-ai": "0.348.0-dev.0",
|
|
27
|
+
"@salutejs/sdds-scan": "0.347.0-dev.0",
|
|
28
|
+
"@salutejs/sdds-serv": "0.348.0-dev.0",
|
|
29
29
|
"@types/react": "18.0.28",
|
|
30
30
|
"@types/react-dom": "18.0.11",
|
|
31
31
|
"react": "18.2.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "3f13e42d1632dd42f62e4053676c718483757523"
|
|
38
38
|
}
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import { useRef, useState } from 'react';
|
|
12
12
|
import { describe, it } from 'vitest';
|
|
13
13
|
import { expectTypeOf } from 'expect-type';
|
|
14
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
14
15
|
import { Button, Cell, Select } from '@salutejs/plasma-b2c';
|
|
15
16
|
|
|
16
17
|
type SelectProps = ComponentProps<typeof Select>;
|
|
@@ -210,6 +211,19 @@ describe('Unions', () => {
|
|
|
210
211
|
name: 'country',
|
|
211
212
|
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => e.target.value,
|
|
212
213
|
});
|
|
214
|
+
expectTypeOf<SelectProps>({
|
|
215
|
+
items: [],
|
|
216
|
+
name: 'country',
|
|
217
|
+
value: '',
|
|
218
|
+
onChange: (value: string) => value,
|
|
219
|
+
});
|
|
220
|
+
expectTypeOf<SelectProps>({
|
|
221
|
+
items: [],
|
|
222
|
+
name: 'country',
|
|
223
|
+
multiselect: true,
|
|
224
|
+
value: ['value'],
|
|
225
|
+
onChange: (value: string[]) => value,
|
|
226
|
+
});
|
|
213
227
|
|
|
214
228
|
// @ts-expect-error
|
|
215
229
|
expectTypeOf<SelectProps>({ items: [], multiselect: false, value: [] });
|
|
@@ -224,9 +238,20 @@ describe('Unions', () => {
|
|
|
224
238
|
// @ts-expect-error
|
|
225
239
|
expectTypeOf<SelectProps>({ items: [], selectAllOptions: { label: 'All' } });
|
|
226
240
|
// @ts-expect-error
|
|
227
|
-
expectTypeOf<SelectProps>({
|
|
241
|
+
expectTypeOf<SelectProps>({
|
|
242
|
+
items: [],
|
|
243
|
+
name: 'country',
|
|
244
|
+
value: '',
|
|
245
|
+
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => e.target.value,
|
|
246
|
+
});
|
|
228
247
|
// @ts-expect-error
|
|
229
|
-
expectTypeOf<SelectProps>({
|
|
248
|
+
expectTypeOf<SelectProps>({
|
|
249
|
+
items: [],
|
|
250
|
+
name: 'country',
|
|
251
|
+
multiselect: true,
|
|
252
|
+
value: ['value'],
|
|
253
|
+
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => e.target.value,
|
|
254
|
+
});
|
|
230
255
|
});
|
|
231
256
|
|
|
232
257
|
it('HintProps', () => {
|
|
@@ -465,7 +490,82 @@ describe('Examples', () => {
|
|
|
465
490
|
|
|
466
491
|
it('Uncontrolled', () => {
|
|
467
492
|
() => {
|
|
468
|
-
return
|
|
493
|
+
return (
|
|
494
|
+
<>
|
|
495
|
+
<Select items={items} label="Label" placeholder="Placeholder" />
|
|
496
|
+
|
|
497
|
+
<Select
|
|
498
|
+
items={items}
|
|
499
|
+
defaultValue="north_america"
|
|
500
|
+
label="Label"
|
|
501
|
+
placeholder="Placeholder"
|
|
502
|
+
onChange={(value, item) => item?.value || value}
|
|
503
|
+
/>
|
|
504
|
+
|
|
505
|
+
<Select
|
|
506
|
+
multiselect
|
|
507
|
+
items={items}
|
|
508
|
+
defaultValue={['north_america']}
|
|
509
|
+
label="Label"
|
|
510
|
+
placeholder="Placeholder"
|
|
511
|
+
onChange={(value, item) => item?.value || value.join(',')}
|
|
512
|
+
/>
|
|
513
|
+
</>
|
|
514
|
+
);
|
|
515
|
+
};
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
it('react-hook-form register', () => {
|
|
519
|
+
() => {
|
|
520
|
+
const { register: registerSingle } = useForm<{ region: string }>({
|
|
521
|
+
defaultValues: {
|
|
522
|
+
region: 'north_america',
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
const { register: registerMultiple } = useForm<{ region: string[] }>({
|
|
526
|
+
defaultValues: {
|
|
527
|
+
region: ['north_america'],
|
|
528
|
+
},
|
|
529
|
+
});
|
|
530
|
+
|
|
531
|
+
return (
|
|
532
|
+
<>
|
|
533
|
+
<Select items={items} {...registerSingle('region')} />
|
|
534
|
+
|
|
535
|
+
<Select multiselect items={items} {...registerMultiple('region')} />
|
|
536
|
+
</>
|
|
537
|
+
);
|
|
538
|
+
};
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
it('react-hook-form Controller', () => {
|
|
542
|
+
() => {
|
|
543
|
+
const { control: singleControl } = useForm<{ region: string }>({
|
|
544
|
+
defaultValues: {
|
|
545
|
+
region: 'north_america',
|
|
546
|
+
},
|
|
547
|
+
});
|
|
548
|
+
const { control: multipleControl } = useForm<{ region: string[] }>({
|
|
549
|
+
defaultValues: {
|
|
550
|
+
region: ['north_america'],
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
return (
|
|
555
|
+
<>
|
|
556
|
+
<Controller
|
|
557
|
+
name="region"
|
|
558
|
+
control={singleControl}
|
|
559
|
+
render={({ field }) => <Select items={items} {...field} />}
|
|
560
|
+
/>
|
|
561
|
+
|
|
562
|
+
<Controller
|
|
563
|
+
name="region"
|
|
564
|
+
control={multipleControl}
|
|
565
|
+
render={({ field }) => <Select multiselect items={items} {...field} />}
|
|
566
|
+
/>
|
|
567
|
+
</>
|
|
568
|
+
);
|
|
469
569
|
};
|
|
470
570
|
});
|
|
471
571
|
|