@salutejs/sdds-api-tests 0.31.1-canary.3323.39941770559.0 → 0.32.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.
|
|
3
|
+
"version": "0.32.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 && NODE_OPTIONS=--max-old-space-size=8192 tsc --noEmit -p ./tsconfig.typecheck.json"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@salutejs/plasma-b2c": "1.
|
|
17
|
-
"@salutejs/plasma-giga": "0.
|
|
18
|
-
"@salutejs/plasma-icons": "1.
|
|
19
|
-
"@salutejs/plasma-web": "1.
|
|
20
|
-
"@salutejs/sdds-bizcom": "0.
|
|
21
|
-
"@salutejs/sdds-cs": "0.
|
|
22
|
-
"@salutejs/sdds-dfa": "0.
|
|
23
|
-
"@salutejs/sdds-finai": "0.
|
|
24
|
-
"@salutejs/sdds-insol": "0.
|
|
25
|
-
"@salutejs/sdds-netology": "0.
|
|
26
|
-
"@salutejs/sdds-platform-ai": "0.
|
|
27
|
-
"@salutejs/sdds-scan": "0.
|
|
28
|
-
"@salutejs/sdds-serv": "0.
|
|
16
|
+
"@salutejs/plasma-b2c": "1.643.0-dev.0",
|
|
17
|
+
"@salutejs/plasma-giga": "0.370.0-dev.0",
|
|
18
|
+
"@salutejs/plasma-icons": "1.256.0-dev.0",
|
|
19
|
+
"@salutejs/plasma-web": "1.645.0-dev.0",
|
|
20
|
+
"@salutejs/sdds-bizcom": "0.375.0-dev.0",
|
|
21
|
+
"@salutejs/sdds-cs": "0.379.0-dev.0",
|
|
22
|
+
"@salutejs/sdds-dfa": "0.373.0-dev.0",
|
|
23
|
+
"@salutejs/sdds-finai": "0.366.0-dev.0",
|
|
24
|
+
"@salutejs/sdds-insol": "0.370.0-dev.0",
|
|
25
|
+
"@salutejs/sdds-netology": "0.374.0-dev.0",
|
|
26
|
+
"@salutejs/sdds-platform-ai": "0.374.0-dev.0",
|
|
27
|
+
"@salutejs/sdds-scan": "0.373.0-dev.0",
|
|
28
|
+
"@salutejs/sdds-serv": "0.374.0-dev.0",
|
|
29
29
|
"@types/node": "^25.9.1",
|
|
30
30
|
"@types/react": "18.0.28",
|
|
31
31
|
"@types/react-dom": "18.0.11",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "94adf03e70ca38ce7316e001562f4fdfe0d8b6cf"
|
|
39
39
|
}
|
package/script.mjs
CHANGED
|
@@ -28,7 +28,7 @@ const config = {
|
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
name: '@salutejs/sdds-cs',
|
|
31
|
-
excludeComponents: ['Select', 'InformationWrapper', 'CodeArea', 'BottomSheet'],
|
|
31
|
+
excludeComponents: ['RatingInput', 'Select', 'InformationWrapper', 'CodeArea', 'BottomSheet'],
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
name: '@salutejs/sdds-dfa',
|
|
@@ -36,19 +36,19 @@ const config = {
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
name: '@salutejs/sdds-finai',
|
|
39
|
-
excludeComponents: ['CodeArea', 'BottomSheet'],
|
|
39
|
+
excludeComponents: ['RatingInput', 'CodeArea', 'BottomSheet'],
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
name: '@salutejs/sdds-insol',
|
|
43
|
-
excludeComponents: ['CodeArea', 'BottomSheet'],
|
|
43
|
+
excludeComponents: ['RatingInput', 'CodeArea', 'BottomSheet'],
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
name: '@salutejs/sdds-netology',
|
|
47
|
-
excludeComponents: ['CodeArea', 'BottomSheet'],
|
|
47
|
+
excludeComponents: ['RatingInput', 'CodeArea', 'BottomSheet'],
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
name: '@salutejs/sdds-platform-ai',
|
|
51
|
-
excludeComponents: ['CodeArea', 'BottomSheet'],
|
|
51
|
+
excludeComponents: ['RatingInput', 'CodeArea', 'BottomSheet'],
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
name: '@salutejs/sdds-scan',
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AriaRole, ComponentProps, CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import { describe, it } from 'node:test';
|
|
4
|
+
import { expectTypeOf } from 'expect-type';
|
|
5
|
+
import { RatingInput } from '@salutejs/plasma-b2c';
|
|
6
|
+
|
|
7
|
+
type Props = ComponentProps<typeof RatingInput>;
|
|
8
|
+
|
|
9
|
+
describe('RatingInput API', () => {
|
|
10
|
+
it('Common', () => {
|
|
11
|
+
expectTypeOf<Props>().toHaveProperty('value').toEqualTypeOf<number | null | undefined>();
|
|
12
|
+
expectTypeOf<Props>().toHaveProperty('defaultValue').toEqualTypeOf<number | null | undefined>();
|
|
13
|
+
expectTypeOf<Props>().toHaveProperty('name').toEqualTypeOf<string | undefined>();
|
|
14
|
+
expectTypeOf<Props>().toHaveProperty('allowClear').toEqualTypeOf<boolean | undefined>();
|
|
15
|
+
expectTypeOf<Props>().toHaveProperty('hasValue').toEqualTypeOf<boolean | undefined>();
|
|
16
|
+
expectTypeOf<Props>().toHaveProperty('hasLimitLabels').toEqualTypeOf<boolean | undefined>();
|
|
17
|
+
expectTypeOf<Props>().toHaveProperty('fractions').toEqualTypeOf<number | undefined>();
|
|
18
|
+
expectTypeOf<Props>().toHaveProperty('iconQuantity').toEqualTypeOf<number | undefined>();
|
|
19
|
+
expectTypeOf<Props>().toHaveProperty('valuePlacement').toEqualTypeOf<'top' | 'bottom' | undefined>();
|
|
20
|
+
expectTypeOf<Props>().toHaveProperty('valueAlign').toEqualTypeOf<'start' | 'center' | undefined>();
|
|
21
|
+
expectTypeOf<Props>().toHaveProperty('limitLabelsPlacement').toEqualTypeOf<'side' | 'bottom' | undefined>();
|
|
22
|
+
expectTypeOf<Props>().toHaveProperty('minLabel').toEqualTypeOf<string | undefined>();
|
|
23
|
+
expectTypeOf<Props>().toHaveProperty('maxLabel').toEqualTypeOf<string | undefined>();
|
|
24
|
+
expectTypeOf<Props>().toHaveProperty('iconSlot').toEqualTypeOf<ReactNode>();
|
|
25
|
+
expectTypeOf<Props>().toHaveProperty('iconSlotOutline').toEqualTypeOf<ReactNode>();
|
|
26
|
+
expectTypeOf<Props>().toHaveProperty('onChange').toEqualTypeOf<((value: number | null) => void) | undefined>();
|
|
27
|
+
expectTypeOf<Props>()
|
|
28
|
+
.toHaveProperty('onHoverChange')
|
|
29
|
+
.toEqualTypeOf<((value: number | null) => void) | undefined>();
|
|
30
|
+
expectTypeOf<Props>()
|
|
31
|
+
.toHaveProperty('renderValue')
|
|
32
|
+
.toEqualTypeOf<((value: number | null) => ReactNode) | undefined>();
|
|
33
|
+
expectTypeOf<Props>().toHaveProperty('getLabelText').toEqualTypeOf<((value: number) => string) | undefined>();
|
|
34
|
+
expectTypeOf<Props>()
|
|
35
|
+
.toHaveProperty('renderFractionIcon')
|
|
36
|
+
.toEqualTypeOf<((filled: number, total: number) => ReactNode) | undefined>();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('HTMLDivElement', () => {
|
|
40
|
+
expectTypeOf<Props>().toHaveProperty('id').toEqualTypeOf<string | undefined>();
|
|
41
|
+
expectTypeOf<Props>().toHaveProperty('className').toEqualTypeOf<string | undefined>();
|
|
42
|
+
expectTypeOf<Props>().toHaveProperty('style').toEqualTypeOf<CSSProperties | undefined>();
|
|
43
|
+
expectTypeOf<Props>().toHaveProperty('role').toEqualTypeOf<AriaRole | undefined>();
|
|
44
|
+
expectTypeOf<Props>().toHaveProperty('aria-label').toEqualTypeOf<string | undefined>();
|
|
45
|
+
expectTypeOf<Props>()
|
|
46
|
+
.toHaveProperty('onKeyDown')
|
|
47
|
+
.toEqualTypeOf<React.KeyboardEventHandler<HTMLDivElement> | undefined>();
|
|
48
|
+
void (<RatingInput ref={React.createRef<HTMLDivElement>()} />);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('Variations', () => {
|
|
52
|
+
type Size = NonNullable<Props['size']>;
|
|
53
|
+
expectTypeOf<Size>().toExtend<string>();
|
|
54
|
+
expectTypeOf<string>().not.toExtend<Size>();
|
|
55
|
+
|
|
56
|
+
type View = NonNullable<Props['view']>;
|
|
57
|
+
expectTypeOf<View>().toExtend<string>();
|
|
58
|
+
expectTypeOf<string>().not.toExtend<View>();
|
|
59
|
+
|
|
60
|
+
type IconSize = NonNullable<Props['iconSize']>;
|
|
61
|
+
expectTypeOf<IconSize>().toExtend<string>();
|
|
62
|
+
expectTypeOf<string>().not.toExtend<IconSize>();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('rejects removed props and non-numeric input values', () => {
|
|
66
|
+
// @ts-expect-error Дробность задается только через fractions.
|
|
67
|
+
expectTypeOf<Props>({ allowHalf: true });
|
|
68
|
+
// @ts-expect-error Кастомные дробные иконки задаются через renderFractionIcon.
|
|
69
|
+
expectTypeOf<Props>({ iconSlotHalf: <span /> });
|
|
70
|
+
// @ts-expect-error Видимое значение задается через renderValue.
|
|
71
|
+
expectTypeOf<Props>({ displayValue: 'Хорошо' });
|
|
72
|
+
// @ts-expect-error Оценка является числом или null.
|
|
73
|
+
void (<RatingInput value="3" />);
|
|
74
|
+
// @ts-expect-error Начальная оценка является числом или null.
|
|
75
|
+
void (<RatingInput defaultValue="3" />);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('supports controlled values, null resets and fraction icon renderers', () => {
|
|
79
|
+
() => {
|
|
80
|
+
const [value, setValue] = React.useState<number | null>(null);
|
|
81
|
+
return (
|
|
82
|
+
<RatingInput
|
|
83
|
+
value={value}
|
|
84
|
+
onChange={setValue}
|
|
85
|
+
allowClear
|
|
86
|
+
name="rating"
|
|
87
|
+
fractions={4}
|
|
88
|
+
hasValue
|
|
89
|
+
renderValue={(selected) => selected ?? 'Выберите оценку'}
|
|
90
|
+
renderFractionIcon={(filled, total) => (
|
|
91
|
+
<span>
|
|
92
|
+
{filled}/{total}
|
|
93
|
+
</span>
|
|
94
|
+
)}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
});
|