@salutejs/sdds-api-tests 0.10.0-next-platform-ai.0 → 0.10.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.10.0-next-platform-ai.0",
3
+ "version": "0.10.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.621.0-next-platform-ai.0",
17
- "@salutejs/plasma-giga": "0.348.0-next-platform-ai.0",
18
- "@salutejs/plasma-icons": "1.239.0-next-platform-ai.0",
19
- "@salutejs/plasma-web": "1.623.0-next-platform-ai.0",
20
- "@salutejs/sdds-bizcom": "0.353.0-next-platform-ai.0",
21
- "@salutejs/sdds-cs": "0.357.0-next-platform-ai.0",
22
- "@salutejs/sdds-dfa": "0.351.0-next-platform-ai.0",
23
- "@salutejs/sdds-finai": "0.344.0-next-platform-ai.0",
24
- "@salutejs/sdds-insol": "0.348.0-next-platform-ai.0",
25
- "@salutejs/sdds-netology": "0.352.0-next-platform-ai.0",
26
- "@salutejs/sdds-platform-ai": "0.352.0-next-platform-ai.0",
27
- "@salutejs/sdds-scan": "0.351.0-next-platform-ai.0",
28
- "@salutejs/sdds-serv": "0.352.0-next-platform-ai.0",
16
+ "@salutejs/plasma-b2c": "1.621.0",
17
+ "@salutejs/plasma-giga": "0.348.0",
18
+ "@salutejs/plasma-icons": "1.239.0",
19
+ "@salutejs/plasma-web": "1.623.0",
20
+ "@salutejs/sdds-bizcom": "0.353.0",
21
+ "@salutejs/sdds-cs": "0.357.0",
22
+ "@salutejs/sdds-dfa": "0.351.0",
23
+ "@salutejs/sdds-finai": "0.344.0",
24
+ "@salutejs/sdds-insol": "0.348.0",
25
+ "@salutejs/sdds-netology": "0.352.0",
26
+ "@salutejs/sdds-platform-ai": "0.352.0",
27
+ "@salutejs/sdds-scan": "0.351.0",
28
+ "@salutejs/sdds-serv": "0.352.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": "b604477f17c0e2ea4d6cc37020432d3b9e2a3cb0"
38
+ "gitHead": "11abf991079928e06b77546d823d7259d0365187"
39
39
  }
@@ -0,0 +1,132 @@
1
+ import * as React from 'react';
2
+ import type { ComponentProps, ReactNode, CSSProperties, AriaRole, HTMLAttributes } from 'react';
3
+ import { describe, it } from 'node:test';
4
+ import { expectTypeOf } from 'expect-type';
5
+ import { Accordion, AccordionItem } from '@salutejs/plasma-b2c';
6
+
7
+ type AccordionProps = ComponentProps<typeof Accordion>;
8
+ type AccordionItemProps = ComponentProps<typeof AccordionItem>;
9
+
10
+ describe('Accordion', () => {
11
+ describe('Basics', () => {
12
+ it('Common', () => {
13
+ expectTypeOf<AccordionProps>().toHaveProperty('singleActive').toEqualTypeOf<boolean | undefined>();
14
+ expectTypeOf<AccordionProps>()
15
+ .toHaveProperty('defaultActiveEventKey')
16
+ .toEqualTypeOf<number[] | undefined>();
17
+ expectTypeOf<AccordionProps>().toHaveProperty('disabled').toEqualTypeOf<boolean | undefined>();
18
+ expectTypeOf<AccordionProps>().toHaveProperty('stretching').toEqualTypeOf<'fixed' | 'filled' | undefined>();
19
+ expectTypeOf<AccordionProps>()
20
+ .toHaveProperty('onChange')
21
+ .toEqualTypeOf<((index?: number, value?: boolean) => void) | undefined>();
22
+ expectTypeOf<AccordionProps>().toHaveProperty('children').toEqualTypeOf<ReactNode>();
23
+ expectTypeOf<AccordionProps>().toHaveProperty('className').toEqualTypeOf<string | undefined>();
24
+ });
25
+
26
+ it('Variations', () => {
27
+ type View = NonNullable<AccordionProps['view']>;
28
+ expectTypeOf<View>().toExtend<string>();
29
+ expectTypeOf<string>().not.toExtend<View>();
30
+
31
+ type Size = NonNullable<AccordionProps['size']>;
32
+ expectTypeOf<Size>().toExtend<string>();
33
+ expectTypeOf<string>().not.toExtend<Size>();
34
+ });
35
+
36
+ it('HTMLDivElement', () => {
37
+ expectTypeOf<AccordionProps>().toHaveProperty('id').toEqualTypeOf<string | undefined>();
38
+ expectTypeOf<AccordionProps>().toHaveProperty('style').toEqualTypeOf<CSSProperties | undefined>();
39
+ expectTypeOf<AccordionProps>().toHaveProperty('aria-label').toEqualTypeOf<string | undefined>();
40
+ expectTypeOf<AccordionProps>().toHaveProperty('role').toEqualTypeOf<AriaRole | undefined>();
41
+ expectTypeOf<AccordionProps>()
42
+ .toHaveProperty('onClick')
43
+ .toEqualTypeOf<React.MouseEventHandler<HTMLDivElement> | undefined>();
44
+ // Microdata support
45
+ expectTypeOf<AccordionProps>().toHaveProperty('itemScope').toEqualTypeOf<boolean | undefined>();
46
+ expectTypeOf<AccordionProps>().toHaveProperty('itemType').toEqualTypeOf<string | undefined>();
47
+ expectTypeOf<AccordionProps>().toHaveProperty('itemProp').toEqualTypeOf<string | undefined>();
48
+ });
49
+ });
50
+ });
51
+
52
+ describe('AccordionItem', () => {
53
+ describe('Basics', () => {
54
+ it('Common', () => {
55
+ expectTypeOf<AccordionItemProps>().toHaveProperty('value').toEqualTypeOf<boolean | undefined>();
56
+ expectTypeOf<AccordionItemProps>()
57
+ .toHaveProperty('type')
58
+ .toEqualTypeOf<'clear' | 'arrow' | 'sign' | undefined>();
59
+ expectTypeOf<AccordionItemProps>().toHaveProperty('contentLeft').toEqualTypeOf<ReactNode>();
60
+ expectTypeOf<AccordionItemProps>().toHaveProperty('alignWithTitle').toEqualTypeOf<boolean | undefined>();
61
+ expectTypeOf<AccordionItemProps>().toHaveProperty('contentRight').toEqualTypeOf<ReactNode>();
62
+ expectTypeOf<AccordionItemProps>()
63
+ .toHaveProperty('pin')
64
+ .toEqualTypeOf<
65
+ | 'square-square'
66
+ | 'square-clear'
67
+ | 'clear-square'
68
+ | 'clear-clear'
69
+ | 'clear-circle'
70
+ | 'circle-clear'
71
+ | 'circle-circle'
72
+ | undefined
73
+ >();
74
+ expectTypeOf<AccordionItemProps>().toHaveProperty('title').toEqualTypeOf<ReactNode>();
75
+ expectTypeOf<AccordionItemProps>().toHaveProperty('children').toEqualTypeOf<ReactNode>();
76
+ expectTypeOf<AccordionItemProps>().toHaveProperty('disabled').toEqualTypeOf<boolean | undefined>();
77
+ expectTypeOf<AccordionItemProps>().toHaveProperty('opened').toEqualTypeOf<boolean | undefined>();
78
+ expectTypeOf<AccordionItemProps>()
79
+ .toHaveProperty('titleProps')
80
+ .toEqualTypeOf<HTMLAttributes<HTMLElement> | undefined>();
81
+ expectTypeOf<AccordionItemProps>()
82
+ .toHaveProperty('bodyProps')
83
+ .toEqualTypeOf<HTMLAttributes<HTMLDivElement> | undefined>();
84
+ });
85
+
86
+ it('HTMLElement', () => {
87
+ expectTypeOf<AccordionItemProps>().toHaveProperty('id').toEqualTypeOf<string | undefined>();
88
+ expectTypeOf<AccordionItemProps>().toHaveProperty('className').toEqualTypeOf<string | undefined>();
89
+ expectTypeOf<AccordionItemProps>().toHaveProperty('style').toEqualTypeOf<CSSProperties | undefined>();
90
+ expectTypeOf<AccordionItemProps>().toHaveProperty('aria-label').toEqualTypeOf<string | undefined>();
91
+ expectTypeOf<AccordionItemProps>().toHaveProperty('role').toEqualTypeOf<AriaRole | undefined>();
92
+ // Microdata support
93
+ expectTypeOf<AccordionItemProps>().toHaveProperty('itemScope').toEqualTypeOf<boolean | undefined>();
94
+ expectTypeOf<AccordionItemProps>().toHaveProperty('itemType').toEqualTypeOf<string | undefined>();
95
+ expectTypeOf<AccordionItemProps>().toHaveProperty('itemProp').toEqualTypeOf<string | undefined>();
96
+ });
97
+ });
98
+ });
99
+
100
+ describe('Examples', () => {
101
+ it('Basic', () => {
102
+ () => (
103
+ <Accordion view="default" singleActive onChange={(index, value) => {}}>
104
+ <AccordionItem title="Первый вопрос">Первый ответ</AccordionItem>
105
+ <AccordionItem title="Второй вопрос" disabled>
106
+ Второй ответ
107
+ </AccordionItem>
108
+ </Accordion>
109
+ );
110
+ });
111
+
112
+ it('Microdata FAQ', () => {
113
+ () => (
114
+ <Accordion itemScope itemType="https://schema.org/FAQPage">
115
+ <AccordionItem
116
+ itemScope
117
+ itemProp="mainEntity"
118
+ itemType="https://schema.org/Question"
119
+ title="Как оформить заказ?"
120
+ titleProps={{ itemProp: 'name' }}
121
+ bodyProps={{
122
+ itemScope: true,
123
+ itemProp: 'acceptedAnswer',
124
+ itemType: 'https://schema.org/Answer',
125
+ }}
126
+ >
127
+ <span itemProp="text">Оформить заказ можно через корзину.</span>
128
+ </AccordionItem>
129
+ </Accordion>
130
+ );
131
+ });
132
+ });