@salutejs/sdds-api-tests 0.3.0-canary.2695.24384614247.0 → 0.3.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.0-canary.2695.24384614247.0",
3
+ "version": "0.3.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.614.0-canary.2695.24384614247.0",
17
- "@salutejs/plasma-giga": "0.341.0-canary.2695.24384614247.0",
18
- "@salutejs/plasma-icons": "1.235.0-canary.2695.24384614247.0",
19
- "@salutejs/plasma-web": "1.616.0-canary.2695.24384614247.0",
20
- "@salutejs/sdds-bizcom": "0.346.0-canary.2695.24384614247.0",
21
- "@salutejs/sdds-cs": "0.350.0-canary.2695.24384614247.0",
22
- "@salutejs/sdds-dfa": "0.344.0-canary.2695.24384614247.0",
23
- "@salutejs/sdds-finai": "0.337.0-canary.2695.24384614247.0",
24
- "@salutejs/sdds-insol": "0.341.0-canary.2695.24384614247.0",
25
- "@salutejs/sdds-netology": "0.345.0-canary.2695.24384614247.0",
26
- "@salutejs/sdds-platform-ai": "0.345.0-canary.2695.24384614247.0",
27
- "@salutejs/sdds-scan": "0.344.0-canary.2695.24384614247.0",
28
- "@salutejs/sdds-serv": "0.345.0-canary.2695.24384614247.0",
16
+ "@salutejs/plasma-b2c": "1.614.0-dev.0",
17
+ "@salutejs/plasma-giga": "0.341.0-dev.0",
18
+ "@salutejs/plasma-icons": "1.235.0-dev.0",
19
+ "@salutejs/plasma-web": "1.616.0-dev.0",
20
+ "@salutejs/sdds-bizcom": "0.346.0-dev.0",
21
+ "@salutejs/sdds-cs": "0.350.0-dev.0",
22
+ "@salutejs/sdds-dfa": "0.344.0-dev.0",
23
+ "@salutejs/sdds-finai": "0.337.0-dev.0",
24
+ "@salutejs/sdds-insol": "0.341.0-dev.0",
25
+ "@salutejs/sdds-netology": "0.345.0-dev.0",
26
+ "@salutejs/sdds-platform-ai": "0.345.0-dev.0",
27
+ "@salutejs/sdds-scan": "0.344.0-dev.0",
28
+ "@salutejs/sdds-serv": "0.345.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": "0fc5bd1c57dc2d6856747b74697969146515c81b"
37
+ "gitHead": "d4fb41099498aa84673f3ee9bd42b097684bcfd1"
38
38
  }
@@ -0,0 +1,106 @@
1
+ import React, { createRef } from 'react';
2
+ import type { ComponentProps } from 'react';
3
+ import { describe, it } from 'vitest';
4
+ import { expectTypeOf } from 'expect-type';
5
+ import { TextL } from '@salutejs/plasma-b2c';
6
+
7
+ type TextLProps = ComponentProps<typeof TextL>;
8
+
9
+ describe('Basics', () => {
10
+ it('Common props', () => {
11
+ expectTypeOf<TextLProps>().toHaveProperty('color').toEqualTypeOf<string | undefined>();
12
+ expectTypeOf<TextLProps>().toHaveProperty('noWrap').toEqualTypeOf<boolean | undefined>();
13
+ expectTypeOf<TextLProps>().toHaveProperty('breakWord').toEqualTypeOf<boolean | undefined>();
14
+ expectTypeOf<TextLProps>().toHaveProperty('isNumeric').toEqualTypeOf<boolean | undefined>();
15
+ expectTypeOf<TextLProps>().toHaveProperty('isItalic').toEqualTypeOf<boolean | undefined>();
16
+ });
17
+
18
+ it('Font weight props', () => {
19
+ expectTypeOf<TextLProps>().toHaveProperty('bold');
20
+ expectTypeOf<TextLProps>().toHaveProperty('medium');
21
+ expectTypeOf<TextLProps>().toHaveProperty('extraBold');
22
+ });
23
+
24
+ it('Font size props', () => {
25
+ expectTypeOf<TextLProps>().toHaveProperty('size');
26
+ expectTypeOf<TextLProps>({ size: 'l' });
27
+ // @ts-expect-error — Размера 'm' не существует
28
+ expectTypeOf<TextLProps>({ size: 'm' });
29
+ });
30
+ });
31
+
32
+ describe('Unions (FontWeight)', () => {
33
+ it('Allowed weight combinations', () => {
34
+ expectTypeOf<TextLProps>({ bold: true });
35
+ expectTypeOf<TextLProps>({ medium: true });
36
+ expectTypeOf<TextLProps>({ extraBold: true });
37
+ expectTypeOf<TextLProps>({ bold: false, medium: true });
38
+ expectTypeOf<TextLProps>({ bold: false, extraBold: true });
39
+ // @ts-expect-error - нельзя одновременно задавать medium=true и extraBold=true
40
+ expectTypeOf<TextLProps>({ bold: true, extraBold: true, medium: true });
41
+ });
42
+ });
43
+
44
+ describe('Generics (polymorphic `as`)', () => {
45
+ it('Allowed tags for `as`', () => {
46
+ expectTypeOf<TextLProps>({ as: 'div' });
47
+ expectTypeOf<TextLProps>({ as: 'p' });
48
+ expectTypeOf<TextLProps>({ as: 'span' });
49
+ expectTypeOf<TextLProps>({ as: 'h1' });
50
+ expectTypeOf<TextLProps>({ as: 'h2' });
51
+ expectTypeOf<TextLProps>({ as: 'h6' });
52
+ expectTypeOf<TextLProps>({ as: 'label' });
53
+ expectTypeOf<TextLProps>({ as: 'blockquote' });
54
+ expectTypeOf<TextLProps>({ as: 'em' });
55
+ expectTypeOf<TextLProps>({ as: 'code' });
56
+ // @ts-expect-error — тег 'use' не разрешён
57
+ expectTypeOf<TextLProps>({ as: 'use' });
58
+ });
59
+ });
60
+
61
+ describe('Ref typing (polymorphic ref)', () => {
62
+ it('as="h1" → ref: Ref<HTMLHeadingElement>', () => {
63
+ const ok = createRef<HTMLHeadingElement>();
64
+ const bad = createRef<HTMLBodyElement>();
65
+ expectTypeOf(<TextL as="h1" ref={ok} />);
66
+ // @ts-expect-error — HTMLBodyElement несовместим с HTMLHeadingElement
67
+ expectTypeOf(<TextL as="h1" ref={bad} />);
68
+ });
69
+
70
+ it('as="time" → ref: Ref<HTMLTimeElement>', () => {
71
+ const ok = createRef<HTMLTimeElement>();
72
+ const bad = createRef<HTMLBodyElement>();
73
+ expectTypeOf(<TextL as="time" ref={ok} />);
74
+ // @ts-expect-error — HTMLBodyElement несовместим с HTMLTimeElement
75
+ expectTypeOf(<TextL as="time" ref={bad} />);
76
+ });
77
+
78
+ it('as="p" → ref: Ref<HTMLParagraphElement>', () => {
79
+ const ok = createRef<HTMLParagraphElement>();
80
+ const bad = createRef<HTMLBodyElement>();
81
+ expectTypeOf(<TextL as="p" ref={ok} />);
82
+ // @ts-expect-error — HTMLBodyElement несовместим с HTMLParagraphElement
83
+ expectTypeOf(<TextL as="p" ref={bad} />);
84
+ });
85
+
86
+ it('as="label" → ref: Ref<HTMLLabelElement>', () => {
87
+ const ok = createRef<HTMLLabelElement>();
88
+ const bad = createRef<HTMLBodyElement>();
89
+ expectTypeOf(<TextL as="label" ref={ok} />);
90
+ // @ts-expect-error — HTMLBodyElement несовместим с HTMLLabelElement
91
+ expectTypeOf(<TextL as="label" ref={bad} />);
92
+ });
93
+
94
+ it('as="blockquote" → ref: Ref<HTMLQuoteElement>', () => {
95
+ const ok = createRef<HTMLQuoteElement>();
96
+ const bad = createRef<HTMLBodyElement>();
97
+ expectTypeOf(<TextL as="blockquote" ref={ok} />);
98
+ // @ts-expect-error — HTMLBodyElement несовместим с HTMLQuoteElement
99
+ expectTypeOf(<TextL as="blockquote" ref={bad} />);
100
+ });
101
+
102
+ it('as="div" → ref: Ref<HTMLHeadingElement>', () => {
103
+ const ok = createRef<HTMLHeadingElement>();
104
+ expectTypeOf(<TextL as="div" ref={ok} />);
105
+ });
106
+ });