@salutejs/sdds-api-tests 0.4.0 → 0.4.1-canary.2678.24886972433.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.4.0",
3
+ "version": "0.4.1-canary.2678.24886972433.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.615.0",
17
- "@salutejs/plasma-giga": "0.342.0",
18
- "@salutejs/plasma-icons": "1.235.0",
19
- "@salutejs/plasma-web": "1.617.0",
20
- "@salutejs/sdds-bizcom": "0.347.0",
21
- "@salutejs/sdds-cs": "0.351.0",
22
- "@salutejs/sdds-dfa": "0.345.0",
23
- "@salutejs/sdds-finai": "0.338.0",
24
- "@salutejs/sdds-insol": "0.342.0",
25
- "@salutejs/sdds-netology": "0.346.0",
26
- "@salutejs/sdds-platform-ai": "0.346.0",
27
- "@salutejs/sdds-scan": "0.345.0",
28
- "@salutejs/sdds-serv": "0.346.0",
16
+ "@salutejs/plasma-b2c": "1.615.1-canary.2678.24886972433.0",
17
+ "@salutejs/plasma-giga": "0.342.1-canary.2678.24886972433.0",
18
+ "@salutejs/plasma-icons": "1.235.1-canary.2678.24886972433.0",
19
+ "@salutejs/plasma-web": "1.617.1-canary.2678.24886972433.0",
20
+ "@salutejs/sdds-bizcom": "0.347.1-canary.2678.24886972433.0",
21
+ "@salutejs/sdds-cs": "0.351.1-canary.2678.24886972433.0",
22
+ "@salutejs/sdds-dfa": "0.345.1-canary.2678.24886972433.0",
23
+ "@salutejs/sdds-finai": "0.338.1-canary.2678.24886972433.0",
24
+ "@salutejs/sdds-insol": "0.342.1-canary.2678.24886972433.0",
25
+ "@salutejs/sdds-netology": "0.346.1-canary.2678.24886972433.0",
26
+ "@salutejs/sdds-platform-ai": "0.346.1-canary.2678.24886972433.0",
27
+ "@salutejs/sdds-scan": "0.345.1-canary.2678.24886972433.0",
28
+ "@salutejs/sdds-serv": "0.346.1-canary.2678.24886972433.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": "a7cba4d3017687e2fef71219f5740b5dc2fd8c81"
37
+ "gitHead": "47c393473cff9c384a2b483719d01d308e8e6cc7"
38
38
  }
@@ -86,3 +86,58 @@ describe('Complex', () => {
86
86
  expectTypeOf<ButtonProps>({ text: 'Hello', value: 'Plasma', stretching: 'filled', contentPlacing: 'default' });
87
87
  });
88
88
  });
89
+
90
+ describe('Polymorphic (as prop)', () => {
91
+ it('as="a" adds anchor props', () => {
92
+ expectTypeOf(<Button as="a" href="/link" target="_blank" />);
93
+ });
94
+
95
+ it('as="a" keeps own props', () => {
96
+ expectTypeOf(<Button as="a" text="text" disabled />);
97
+ expectTypeOf(<Button as="a" text="text" isLoading />);
98
+ });
99
+
100
+ it('as custom component adds its props', () => {
101
+ type LinkProps = { to: string; replace?: boolean; children?: React.ReactNode };
102
+ const Link = (_: LinkProps) => null;
103
+
104
+ expectTypeOf(<Button as={Link} to="/link" replace text="text" />);
105
+ });
106
+
107
+ it('as custom component does not add props absent in that component', () => {
108
+ type LinkProps = { to: string; children?: React.ReactNode };
109
+ const Link = (_: LinkProps) => null;
110
+
111
+ // @ts-expect-error
112
+ expectTypeOf(<Button as={Link} href="/link" replace text="text" />);
113
+ });
114
+
115
+ it('as="input" adds input props', () => {
116
+ expectTypeOf(<Button as="input" type="submit" />);
117
+ expectTypeOf(<Button as="input" type="reset" placeholder="..." onChange={() => {}} />);
118
+ });
119
+
120
+ it('as="input" keeps own props', () => {
121
+ expectTypeOf(<Button as="input" text="text" disabled />);
122
+ expectTypeOf(<Button as="input" text="text" isLoading />);
123
+ });
124
+
125
+ it('as="input" does not add anchor props', () => {
126
+ // @ts-expect-error
127
+ expectTypeOf(<Button as="input" href="/link" target="_blank" />);
128
+ });
129
+
130
+ it('as="div" adds div props', () => {
131
+ expectTypeOf(<Button as="div" tabIndex={0} contentEditable />);
132
+ });
133
+
134
+ it('as="div" keeps own props', () => {
135
+ expectTypeOf(<Button as="div" text="text" disabled />);
136
+ expectTypeOf(<Button as="div" text="text" isLoading />);
137
+ });
138
+
139
+ it('as="div" does not add anchor props', () => {
140
+ // @ts-expect-error
141
+ expectTypeOf(<Button as="div" href="/link" target="_blank" />);
142
+ });
143
+ });