@expo/html-elements 0.12.2 → 0.12.4

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/css/createSafeStyledView.native.d.ts +1 -1
  3. package/build/css/createSafeStyledView.native.d.ts.map +1 -1
  4. package/build/elements/Anchor.d.ts +2 -2
  5. package/build/elements/Anchor.d.ts.map +1 -1
  6. package/build/elements/Headings.d.ts.map +1 -1
  7. package/build/elements/Layout.d.ts.map +1 -1
  8. package/build/elements/Lists.d.ts +2 -2
  9. package/build/elements/Lists.d.ts.map +1 -1
  10. package/build/elements/Rules.d.ts +2 -2
  11. package/build/elements/Rules.d.ts.map +1 -1
  12. package/build/elements/Rules.web.d.ts +1 -2
  13. package/build/elements/Rules.web.d.ts.map +1 -1
  14. package/build/elements/Table.d.ts +9 -9
  15. package/build/elements/Table.d.ts.map +1 -1
  16. package/build/elements/Table.web.d.ts.map +1 -1
  17. package/build/elements/Text.d.ts +15 -15
  18. package/build/elements/Text.d.ts.map +1 -1
  19. package/build/primitives/RNWView.d.ts +4 -2
  20. package/build/primitives/RNWView.d.ts.map +1 -1
  21. package/build/primitives/createDevView.d.ts +1 -1
  22. package/build/primitives/createDevView.d.ts.map +1 -1
  23. package/jest-setup.js +1 -0
  24. package/package.json +13 -7
  25. package/{build/Elements.js → src/Elements.tsx} +0 -1
  26. package/src/css/__tests__/__snapshots__/createSafeStyledView.test.native.tsx.snap.android +31 -0
  27. package/src/css/__tests__/__snapshots__/createSafeStyledView.test.native.tsx.snap.ios +31 -0
  28. package/src/css/__tests__/createSafeStyledView.test.native.tsx +54 -0
  29. package/src/css/createSafeStyledView.native.tsx +12 -0
  30. package/src/css/createSafeStyledView.tsx +4 -0
  31. package/src/css/filterStyles.ts +92 -0
  32. package/src/css/units.ts +11 -0
  33. package/src/elements/Anchor.tsx +27 -0
  34. package/src/elements/Headings.tsx +81 -0
  35. package/src/elements/Layout.tsx +72 -0
  36. package/src/elements/Lists.tsx +45 -0
  37. package/src/elements/Rules.tsx +18 -0
  38. package/src/elements/Rules.web.tsx +7 -0
  39. package/src/elements/Table.tsx +59 -0
  40. package/src/elements/Table.web.tsx +38 -0
  41. package/src/elements/Text.tsx +111 -0
  42. package/src/elements/Text.types.ts +21 -0
  43. package/src/elements/__tests__/Anchor.test.ios.tsx +10 -0
  44. package/src/elements/__tests__/Anchor.test.web.tsx +11 -0
  45. package/src/elements/__tests__/Headings.test.ios.tsx +13 -0
  46. package/src/elements/__tests__/Layout.test.ios.tsx +40 -0
  47. package/src/elements/__tests__/Layout.test.web.tsx +50 -0
  48. package/src/elements/__tests__/Lists.test.native.tsx +17 -0
  49. package/src/elements/__tests__/Lists.test.web.tsx +41 -0
  50. package/src/elements/__tests__/Rules.test.native.tsx +10 -0
  51. package/src/elements/__tests__/Rules.test.web.tsx +8 -0
  52. package/src/elements/__tests__/Table.test.ios.tsx +45 -0
  53. package/src/elements/__tests__/Table.test.web.tsx +49 -0
  54. package/src/elements/__tests__/Text.test.ios.tsx +102 -0
  55. package/src/elements/__tests__/__snapshots__/Anchor-test.tsx.snap.android +8 -0
  56. package/src/elements/__tests__/__snapshots__/Anchor-test.tsx.snap.ios +8 -0
  57. package/src/elements/__tests__/__snapshots__/Anchor-test.tsx.snap.web +12 -0
  58. package/src/elements/__tests__/__snapshots__/Anchor.test.ios.tsx.snap.ios +8 -0
  59. package/src/elements/__tests__/__snapshots__/Anchor.test.tsx.snap.android +8 -0
  60. package/src/elements/__tests__/__snapshots__/Anchor.test.tsx.snap.ios +8 -0
  61. package/src/elements/__tests__/__snapshots__/Anchor.test.tsx.snap.web +12 -0
  62. package/src/elements/__tests__/__snapshots__/Headings-test.tsx.snap.android +79 -0
  63. package/src/elements/__tests__/__snapshots__/Headings-test.tsx.snap.ios +79 -0
  64. package/src/elements/__tests__/__snapshots__/Headings-test.tsx.snap.web +61 -0
  65. package/src/elements/__tests__/__snapshots__/Headings.test.ios.tsx.snap.ios +79 -0
  66. package/src/elements/__tests__/__snapshots__/Layout-test.tsx.snap.android +23 -0
  67. package/src/elements/__tests__/__snapshots__/Layout-test.tsx.snap.ios +23 -0
  68. package/src/elements/__tests__/__snapshots__/Layout-test.tsx.snap.web +64 -0
  69. package/src/elements/__tests__/__snapshots__/Layout.test.ios.tsx.snap.ios +23 -0
  70. package/src/elements/__tests__/__snapshots__/Layout.test.tsx.snap.android +23 -0
  71. package/src/elements/__tests__/__snapshots__/Layout.test.tsx.snap.ios +23 -0
  72. package/src/elements/__tests__/__snapshots__/Layout.test.tsx.snap.web +64 -0
  73. package/src/elements/__tests__/__snapshots__/Lists-test.tsx.snap.android +14 -0
  74. package/src/elements/__tests__/__snapshots__/Lists-test.tsx.snap.ios +14 -0
  75. package/src/elements/__tests__/__snapshots__/Lists-test.tsx.snap.web +34 -0
  76. package/src/elements/__tests__/__snapshots__/Lists.test.native.tsx.snap.android +14 -0
  77. package/src/elements/__tests__/__snapshots__/Lists.test.native.tsx.snap.ios +14 -0
  78. package/src/elements/__tests__/__snapshots__/Rules-test.tsx.snap.android +15 -0
  79. package/src/elements/__tests__/__snapshots__/Rules-test.tsx.snap.ios +15 -0
  80. package/src/elements/__tests__/__snapshots__/Rules-test.tsx.snap.web +7 -0
  81. package/src/elements/__tests__/__snapshots__/Rules.test.native.tsx.snap.android +15 -0
  82. package/src/elements/__tests__/__snapshots__/Rules.test.native.tsx.snap.ios +15 -0
  83. package/src/elements/__tests__/__snapshots__/Table-test.tsx.snap.android +60 -0
  84. package/src/elements/__tests__/__snapshots__/Table-test.tsx.snap.ios +60 -0
  85. package/src/elements/__tests__/__snapshots__/Table-test.tsx.snap.web +71 -0
  86. package/src/elements/__tests__/__snapshots__/Table.test.ios.tsx.snap.ios +60 -0
  87. package/src/elements/__tests__/__snapshots__/Table.test.tsx.snap.android +60 -0
  88. package/src/elements/__tests__/__snapshots__/Table.test.tsx.snap.ios +60 -0
  89. package/src/elements/__tests__/__snapshots__/Table.test.tsx.snap.web +71 -0
  90. package/src/elements/__tests__/__snapshots__/Text-test.tsx.snap.android +174 -0
  91. package/src/elements/__tests__/__snapshots__/Text-test.tsx.snap.ios +174 -0
  92. package/src/elements/__tests__/__snapshots__/Text-test.tsx.snap.web +149 -0
  93. package/src/elements/__tests__/__snapshots__/Text.test.ios.tsx.snap.ios +174 -0
  94. package/src/primitives/Image.tsx +30 -0
  95. package/src/primitives/RNWView.tsx +178 -0
  96. package/src/primitives/Table.ts +14 -0
  97. package/src/primitives/Text.tsx +68 -0
  98. package/src/primitives/View.tsx +145 -0
  99. package/src/primitives/__tests__/__snapshots__/createDevView.test.ios.tsx.snap.ios +35 -0
  100. package/src/primitives/__tests__/__snapshots__/createDevView.test.tsx.snap.android +35 -0
  101. package/src/primitives/__tests__/__snapshots__/createDevView.test.tsx.snap.ios +35 -0
  102. package/src/primitives/__tests__/__snapshots__/createDevView.test.tsx.snap.web +30 -0
  103. package/src/primitives/__tests__/__snapshots__/createDevView.test.web.tsx.snap.web +27 -0
  104. package/src/primitives/__tests__/createDevView.test.tsx +53 -0
  105. package/src/primitives/createDevView.tsx +48 -0
  106. package/src/ts-declarations/process.d.ts +7 -0
  107. package/src/ts-declarations/react-native-web.d.ts +1016 -0
  108. package/tsconfig.json +2 -2
  109. package/build/Elements.js.map +0 -1
  110. package/build/css/createSafeStyledView.js +0 -5
  111. package/build/css/createSafeStyledView.js.map +0 -1
  112. package/build/css/createSafeStyledView.native.js +0 -10
  113. package/build/css/createSafeStyledView.native.js.map +0 -1
  114. package/build/css/filterStyles.js +0 -83
  115. package/build/css/filterStyles.js.map +0 -1
  116. package/build/css/units.js +0 -12
  117. package/build/css/units.js.map +0 -1
  118. package/build/elements/Anchor.js +0 -25
  119. package/build/elements/Anchor.js.map +0 -1
  120. package/build/elements/Headings.js +0 -78
  121. package/build/elements/Headings.js.map +0 -1
  122. package/build/elements/Layout.js +0 -46
  123. package/build/elements/Layout.js.map +0 -1
  124. package/build/elements/Lists.js +0 -33
  125. package/build/elements/Lists.js.map +0 -1
  126. package/build/elements/Rules.js +0 -16
  127. package/build/elements/Rules.js.map +0 -1
  128. package/build/elements/Rules.web.js +0 -6
  129. package/build/elements/Rules.web.js.map +0 -1
  130. package/build/elements/Table.js +0 -50
  131. package/build/elements/Table.js.map +0 -1
  132. package/build/elements/Table.web.js +0 -27
  133. package/build/elements/Table.web.js.map +0 -1
  134. package/build/elements/Text.js +0 -92
  135. package/build/elements/Text.js.map +0 -1
  136. package/build/elements/Text.types.js +0 -2
  137. package/build/elements/Text.types.js.map +0 -1
  138. package/build/primitives/Image.js +0 -5
  139. package/build/primitives/Image.js.map +0 -1
  140. package/build/primitives/RNWView.js +0 -122
  141. package/build/primitives/RNWView.js.map +0 -1
  142. package/build/primitives/Table.js +0 -3
  143. package/build/primitives/Table.js.map +0 -1
  144. package/build/primitives/Text.js +0 -5
  145. package/build/primitives/Text.js.map +0 -1
  146. package/build/primitives/View.js +0 -10
  147. package/build/primitives/View.js.map +0 -1
  148. package/build/primitives/createDevView.js +0 -43
  149. package/build/primitives/createDevView.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ import React, { ComponentType } from 'react';
2
+ import { Platform } from 'react-native';
3
+
4
+ import View, { ViewProps } from '../primitives/View';
5
+
6
+ function createView(nativeProps: ViewProps = {}): ComponentType<ViewProps> {
7
+ return function Dom(props: ViewProps) {
8
+ return <View {...nativeProps} {...props} />;
9
+ };
10
+ }
11
+
12
+ export const Div = createView();
13
+
14
+ export const Nav = createView(
15
+ Platform.select({
16
+ web: {
17
+ role: 'navigation',
18
+ },
19
+ })
20
+ );
21
+ export const Footer = createView(
22
+ Platform.select({
23
+ web: {
24
+ role: 'contentinfo',
25
+ },
26
+ })
27
+ );
28
+ export const Aside = createView(
29
+ Platform.select({
30
+ web: {
31
+ role: 'complementary',
32
+ },
33
+ })
34
+ );
35
+ export const Header = createView(
36
+ Platform.select({
37
+ web: {
38
+ role: 'banner',
39
+ },
40
+ default: {
41
+ accessibilityRole: 'header',
42
+ },
43
+ })
44
+ );
45
+ export const Main = createView(
46
+ Platform.select({
47
+ web: {
48
+ role: 'main',
49
+ },
50
+ })
51
+ );
52
+ export const Article = createView(
53
+ Platform.select({
54
+ web: {
55
+ role: 'article',
56
+ },
57
+ })
58
+ );
59
+ export const Section = createView({
60
+ role: 'summary', // region?
61
+ });
62
+
63
+ if (__DEV__) {
64
+ Div.displayName = 'Div';
65
+ Nav.displayName = 'Nav';
66
+ Footer.displayName = 'Footer';
67
+ Aside.displayName = 'Aside';
68
+ Header.displayName = 'Header';
69
+ Main.displayName = 'Main';
70
+ Article.displayName = 'Article';
71
+ Section.displayName = 'Section';
72
+ }
@@ -0,0 +1,45 @@
1
+ import React, { ComponentType, PropsWithChildren } from 'react';
2
+ import { Platform } from 'react-native';
3
+
4
+ import Text, { TextProps } from '../primitives/Text';
5
+ import View, { ViewProps } from '../primitives/View';
6
+
7
+ function createView(nativeProps: ViewProps = {}): ComponentType<ViewProps> {
8
+ return function Dom(props: ViewProps) {
9
+ return <View {...nativeProps} {...props} />;
10
+ };
11
+ }
12
+
13
+ export const UL = createView(
14
+ Platform.select({
15
+ web: {
16
+ role: 'list',
17
+ },
18
+ })
19
+ );
20
+
21
+ if (__DEV__) {
22
+ UL.displayName = 'UL';
23
+ }
24
+
25
+ function isTextProps(props: any): props is TextProps {
26
+ // Treat <li></li> as a Text element.
27
+ return typeof props.children === 'string';
28
+ }
29
+
30
+ type LIProps = TextProps | ViewProps;
31
+
32
+ export function LI(props: PropsWithChildren<LIProps>) {
33
+ if (isTextProps(props)) {
34
+ const role: LIProps['role'] = Platform.select({
35
+ web: 'listitem',
36
+ default: props.role,
37
+ });
38
+ return <Text {...props} role={role} />;
39
+ }
40
+ const role: LIProps['role'] = Platform.select({
41
+ web: 'listitem',
42
+ default: props.role,
43
+ });
44
+ return <View {...props} role={role} />;
45
+ }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+
4
+ import View, { ViewProps } from '../primitives/View';
5
+
6
+ export function HR(props: ViewProps) {
7
+ return <View {...props} style={[styles.hr, props.style]} />;
8
+ }
9
+
10
+ const styles = StyleSheet.create({
11
+ hr: {
12
+ borderTopWidth: StyleSheet.hairlineWidth,
13
+ borderBottomWidth: StyleSheet.hairlineWidth,
14
+ borderTopColor: '#9A9A9A',
15
+ borderBottomColor: '#EEEEEE',
16
+ marginVertical: 8,
17
+ },
18
+ });
@@ -0,0 +1,7 @@
1
+ import createElement from 'react-native-web/dist/exports/createElement';
2
+
3
+ import { ViewProps } from '../primitives/View';
4
+
5
+ export function HR(props: ViewProps) {
6
+ return createElement('hr', props);
7
+ }
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+
4
+ import { em } from '../css/units';
5
+ import { TableText, TableTextProps } from '../primitives/Table';
6
+ import Text, { TextProps } from '../primitives/Text';
7
+ import View, { ViewProps } from '../primitives/View';
8
+
9
+ export function Table(props: ViewProps) {
10
+ return <View {...props} />;
11
+ }
12
+
13
+ export function THead(props: ViewProps) {
14
+ return <View {...props} />;
15
+ }
16
+
17
+ export function TBody(props: ViewProps) {
18
+ return <View {...props} />;
19
+ }
20
+
21
+ export function TFoot(props: ViewProps) {
22
+ return <View {...props} />;
23
+ }
24
+
25
+ export function TH(props: TableTextProps) {
26
+ return <TableText {...props} style={[styles.th, props.style]} />;
27
+ }
28
+
29
+ export function TR(props: ViewProps) {
30
+ return <View {...props} style={[styles.tr, props.style]} />;
31
+ }
32
+
33
+ export function TD(props: TableTextProps) {
34
+ return <TableText {...props} style={[styles.td, props.style]} />;
35
+ }
36
+
37
+ export function Caption(props: TextProps) {
38
+ return <Text {...props} style={[styles.caption, props.style]} />;
39
+ }
40
+
41
+ const styles = StyleSheet.create({
42
+ caption: {
43
+ textAlign: 'center',
44
+ fontSize: em(1) as number,
45
+ },
46
+ th: {
47
+ textAlign: 'center',
48
+ fontWeight: 'bold',
49
+ flex: 1,
50
+ fontSize: em(1) as number,
51
+ },
52
+ tr: {
53
+ flexDirection: 'row',
54
+ },
55
+ td: {
56
+ flex: 1,
57
+ fontSize: em(1) as number,
58
+ },
59
+ });
@@ -0,0 +1,38 @@
1
+ import React, { ComponentType } from 'react';
2
+
3
+ import View from '../primitives/RNWView';
4
+ import { ViewProps } from '../primitives/View';
5
+
6
+ function createView(nativeProps: ViewProps & { __element: string }): ComponentType<ViewProps> {
7
+ return function Dom(props: ViewProps) {
8
+ // @ts-expect-error - View and ViewProps have no properties in common
9
+ return <View {...nativeProps} {...props} />;
10
+ };
11
+ }
12
+
13
+ export const Table = createView({ __element: 'table' });
14
+
15
+ export const THead = createView({ __element: 'thead' });
16
+
17
+ export const TBody = createView({ __element: 'tbody' });
18
+
19
+ export const TFoot = createView({ __element: 'tfoot' });
20
+
21
+ export const TH = createView({ __element: 'th' });
22
+
23
+ export const TR = createView({ __element: 'tr' });
24
+
25
+ export const TD = createView({ __element: 'td' });
26
+
27
+ export const Caption = createView({ __element: 'caption' });
28
+
29
+ if (__DEV__) {
30
+ Table.displayName = 'Table';
31
+ THead.displayName = 'THead';
32
+ TBody.displayName = 'TBody';
33
+ TFoot.displayName = 'TFoot';
34
+ TH.displayName = 'TH';
35
+ TR.displayName = 'TR';
36
+ TD.displayName = 'TD';
37
+ Caption.displayName = 'Caption';
38
+ }
@@ -0,0 +1,111 @@
1
+ import React from 'react';
2
+ import { StyleSheet, Platform } from 'react-native';
3
+
4
+ import { BlockQuoteProps, QuoteProps, TimeProps } from './Text.types';
5
+ import { em } from '../css/units';
6
+ import Text, { TextProps } from '../primitives/Text';
7
+ import View, { ViewProps } from '../primitives/View';
8
+
9
+ export function P({ style, ...props }: TextProps) {
10
+ return <Text {...props} style={[styles.p, style]} />;
11
+ }
12
+
13
+ export function B({ style, ...props }: TextProps) {
14
+ return <Text {...props} style={[styles.b, style]} />;
15
+ }
16
+
17
+ export function S({ style, ...props }: TextProps) {
18
+ return <Text {...props} style={[styles.s, style]} />;
19
+ }
20
+
21
+ export function I({ style, ...props }: TextProps) {
22
+ return <Text {...props} style={[styles.i, style]} />;
23
+ }
24
+
25
+ export function Q({ children, cite, style, ...props }: QuoteProps) {
26
+ return (
27
+ <Text {...props} style={[styles.q, style]}>
28
+ "{children}"
29
+ </Text>
30
+ );
31
+ }
32
+
33
+ export function BlockQuote({ style, cite, ...props }: BlockQuoteProps) {
34
+ return <View {...props} style={[styles.blockQuote, style]} />;
35
+ }
36
+
37
+ export function BR({ style, ...props }: TextProps) {
38
+ return <Text {...props} style={[styles.br, style]} />;
39
+ }
40
+
41
+ export function Mark({ style, ...props }: TextProps) {
42
+ return <Text {...props} style={[styles.mark, style]} />;
43
+ }
44
+
45
+ export function Code({ style, ...props }: TextProps) {
46
+ return <Text {...props} style={[styles.code, style]} />;
47
+ }
48
+
49
+ function isTextProps(props: any): props is TextProps {
50
+ return typeof props.children === 'string';
51
+ }
52
+
53
+ type PreProps = TextProps | ViewProps;
54
+
55
+ export function Pre(props: PreProps) {
56
+ if (isTextProps(props)) {
57
+ return <Text {...props} style={[styles.code, styles.pre, props.style]} />;
58
+ }
59
+ return <View {...props} style={[styles.pre, props.style]} />;
60
+ }
61
+
62
+ // Extract dateTime to prevent passing it to the native Text element
63
+ export function Time({ dateTime, ...props }: TimeProps) {
64
+ return <Text {...props} />;
65
+ }
66
+
67
+ export const Strong = B;
68
+ export const Del = S;
69
+ export const EM = I;
70
+ export const Span = Text;
71
+
72
+ const styles = StyleSheet.create({
73
+ p: {
74
+ // @ts-ignore
75
+ marginVertical: em(1),
76
+ },
77
+ b: {
78
+ fontWeight: 'bold',
79
+ },
80
+ q: {
81
+ fontStyle: 'italic',
82
+ },
83
+ code: {
84
+ fontFamily: Platform.select({ default: 'Courier', ios: 'Courier New', android: 'monospace' }),
85
+ fontWeight: '500',
86
+ },
87
+ pre: {
88
+ // @ts-ignore
89
+ marginVertical: em(1),
90
+ },
91
+ blockQuote: {
92
+ // @ts-ignore
93
+ marginVertical: em(1),
94
+ },
95
+ br: {
96
+ width: 0,
97
+ // @ts-ignore
98
+ height: em(0.5),
99
+ },
100
+ s: {
101
+ textDecorationLine: 'line-through',
102
+ textDecorationStyle: 'solid',
103
+ },
104
+ mark: {
105
+ backgroundColor: 'yellow',
106
+ color: 'black',
107
+ },
108
+ i: {
109
+ fontStyle: 'italic',
110
+ },
111
+ });
@@ -0,0 +1,21 @@
1
+ import { TextProps } from '../primitives/Text';
2
+ import { ViewProps } from '../primitives/View';
3
+
4
+ export type QuoteProps = React.PropsWithChildren<TextProps & { cite?: string }>;
5
+
6
+ export type BlockQuoteProps = React.PropsWithChildren<ViewProps & { cite?: string }>;
7
+
8
+ export type TimeProps = React.PropsWithChildren<TextProps & { dateTime?: string }>;
9
+
10
+ export type LinkProps = React.PropsWithChildren<
11
+ TextProps & {
12
+ /** @platform web */
13
+ href?: string;
14
+ /** @platform web */
15
+ target?: string;
16
+ /** @platform web */
17
+ rel?: string;
18
+ /** @platform web */
19
+ download?: boolean | string;
20
+ }
21
+ >;
@@ -0,0 +1,10 @@
1
+ import 'react-native';
2
+ import { render } from '@testing-library/react-native';
3
+ import * as React from 'react';
4
+
5
+ import { A } from '../Anchor';
6
+
7
+ it('renders A', () => {
8
+ const { toJSON } = render(<A href="#" target="_parent" />);
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
@@ -0,0 +1,11 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import * as React from 'react';
3
+
4
+ import { A } from '../Anchor';
5
+
6
+ it('renders A', () => {
7
+ render(<A href="#" target="_parent" />);
8
+
9
+ const anchor = screen.getByRole('link');
10
+ expect(anchor).toBeDefined();
11
+ });
@@ -0,0 +1,13 @@
1
+ import 'react-native';
2
+ import { render } from '@testing-library/react-native';
3
+ import * as React from 'react';
4
+
5
+ import * as Headings from '../Headings';
6
+
7
+ const headingComponentNames = Object.keys(Headings);
8
+
9
+ it.each(headingComponentNames)('renders %s', (name) => {
10
+ const Heading = Headings[name];
11
+ const { toJSON } = render(<Heading />);
12
+ expect(toJSON()).toMatchSnapshot();
13
+ });
@@ -0,0 +1,40 @@
1
+ import 'react-native';
2
+ import { render } from '@testing-library/react-native';
3
+ import * as React from 'react';
4
+
5
+ import { Article, Aside, Footer, Header, Main, Nav, Section } from '../Layout';
6
+
7
+ it('renders Footer', () => {
8
+ const { toJSON } = render(<Footer />);
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
11
+
12
+ it('renders Nav', () => {
13
+ const { toJSON } = render(<Nav />);
14
+ expect(toJSON()).toMatchSnapshot();
15
+ });
16
+
17
+ it('renders Aside', () => {
18
+ const { toJSON } = render(<Aside />);
19
+ expect(toJSON()).toMatchSnapshot();
20
+ });
21
+
22
+ it('renders Header', () => {
23
+ const { toJSON } = render(<Header />);
24
+ expect(toJSON()).toMatchSnapshot();
25
+ });
26
+
27
+ it('renders Main', () => {
28
+ const { toJSON } = render(<Main />);
29
+ expect(toJSON()).toMatchSnapshot();
30
+ });
31
+
32
+ it('renders Section', () => {
33
+ const { toJSON } = render(<Section />);
34
+ expect(toJSON()).toMatchSnapshot();
35
+ });
36
+
37
+ it('renders Article', () => {
38
+ const { toJSON } = render(<Article />);
39
+ expect(toJSON()).toMatchSnapshot();
40
+ });
@@ -0,0 +1,50 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import * as React from 'react';
3
+
4
+ import { Article, Aside, Footer, Header, Main, Nav, Section } from '../Layout';
5
+
6
+ it('renders Footer', () => {
7
+ render(<Footer />);
8
+
9
+ const footer = screen.getByRole('contentinfo');
10
+ expect(footer).toBeDefined();
11
+ });
12
+
13
+ it('renders Nav', () => {
14
+ render(<Nav />);
15
+
16
+ const nav = screen.getByRole('navigation');
17
+ expect(nav).toBeDefined();
18
+ });
19
+
20
+ it('renders Aside', () => {
21
+ render(<Aside />);
22
+
23
+ const aside = screen.getByRole('complementary');
24
+ expect(aside).toBeDefined();
25
+ });
26
+
27
+ it('renders Header', () => {
28
+ render(<Header />);
29
+
30
+ const header = screen.getByRole('banner');
31
+ expect(header).toBeDefined();
32
+ });
33
+
34
+ it('renders Main', () => {
35
+ render(<Main />);
36
+ const main = screen.getByRole('main');
37
+ expect(main).toBeDefined();
38
+ });
39
+
40
+ it('renders Section', () => {
41
+ render(<Section />);
42
+ const section = screen.getByRole('region');
43
+ expect(section).toBeDefined();
44
+ });
45
+
46
+ it('renders Article', () => {
47
+ render(<Article />);
48
+ const article = screen.getByRole('article');
49
+ expect(article).toBeDefined();
50
+ });
@@ -0,0 +1,17 @@
1
+ import 'react-native';
2
+ import { render } from '@testing-library/react-native';
3
+ import * as React from 'react';
4
+
5
+ import { LI, UL } from '../Lists';
6
+
7
+ it('renders UL nested in LI', () => {
8
+ const { toJSON } = render(
9
+ <LI>
10
+ <LI>item</LI>
11
+ <UL>
12
+ <LI>item</LI>
13
+ </UL>
14
+ </LI>
15
+ );
16
+ expect(toJSON()).toMatchSnapshot();
17
+ });
@@ -0,0 +1,41 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import * as React from 'react';
3
+
4
+ import { LI, UL } from '../Lists';
5
+
6
+ it('renders UL nested in UL', () => {
7
+ render(
8
+ <UL testID="ul">
9
+ <LI>item</LI>
10
+ <UL>
11
+ <LI>item</LI>
12
+ </UL>
13
+ </UL>
14
+ );
15
+
16
+ const ul = screen.getByTestId('ul');
17
+ expect(ul).toBeDefined();
18
+ });
19
+
20
+ it('renders a single UL with multiple LI children', () => {
21
+ render(
22
+ <UL>
23
+ <LI>item 1</LI>
24
+ <LI>item 2</LI>
25
+ <LI>item 3</LI>
26
+ </UL>
27
+ );
28
+
29
+ const listItems = screen.getAllByRole('listitem');
30
+ expect(listItems[0]).toHaveTextContent(/item 1/);
31
+ expect(listItems[1]).toHaveTextContent(/item 2/);
32
+ expect(listItems[2]).toHaveTextContent(/item 3/);
33
+ expect(listItems[2]).toHaveTextContent('item 3');
34
+ });
35
+
36
+ it('renders an empty UL without crashing', () => {
37
+ render(<UL />);
38
+ const ul = screen.getByRole('list');
39
+ expect(ul).toBeDefined();
40
+ expect(ul.children).toHaveLength(0);
41
+ });
@@ -0,0 +1,10 @@
1
+ import 'react-native';
2
+ import { render } from '@testing-library/react-native';
3
+ import * as React from 'react';
4
+
5
+ import { HR } from '../Rules';
6
+
7
+ it('renders HR', () => {
8
+ const { toJSON } = render(<HR />);
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
@@ -0,0 +1,8 @@
1
+ import { render } from '@testing-library/react';
2
+ import * as React from 'react';
3
+
4
+ import { HR } from '../Rules';
5
+
6
+ it('renders HR', () => {
7
+ render(<HR />);
8
+ });
@@ -0,0 +1,45 @@
1
+ import 'react-native';
2
+ import { render } from '@testing-library/react-native';
3
+ import * as React from 'react';
4
+
5
+ import { Table, THead, TBody, TFoot, TR, TH, TD, Caption } from '../Table';
6
+
7
+ it('renders Table', () => {
8
+ const { toJSON } = render(<Table />);
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
11
+
12
+ it('renders THead', () => {
13
+ const { toJSON } = render(<THead />);
14
+ expect(toJSON()).toMatchSnapshot();
15
+ });
16
+
17
+ it('renders TBody', () => {
18
+ const { toJSON } = render(<TBody />);
19
+ expect(toJSON()).toMatchSnapshot();
20
+ });
21
+
22
+ it('renders TFoot', () => {
23
+ const { toJSON } = render(<TFoot />);
24
+ expect(toJSON()).toMatchSnapshot();
25
+ });
26
+
27
+ it('renders TH', () => {
28
+ const { toJSON } = render(<TH>Header</TH>);
29
+ expect(toJSON()).toMatchSnapshot();
30
+ });
31
+
32
+ it('renders TR', () => {
33
+ const { toJSON } = render(<TR />);
34
+ expect(toJSON()).toMatchSnapshot();
35
+ });
36
+
37
+ it('renders TD', () => {
38
+ const { toJSON } = render(<TD>Column</TD>);
39
+ expect(toJSON()).toMatchSnapshot();
40
+ });
41
+
42
+ it('renders Caption', () => {
43
+ const { toJSON } = render(<Caption>Caption</Caption>);
44
+ expect(toJSON()).toMatchSnapshot();
45
+ });
@@ -0,0 +1,49 @@
1
+ import { render, screen } from '@testing-library/react';
2
+ import * as React from 'react';
3
+
4
+ import { Table, THead, TBody, TFoot, TR, TH, TD, Caption } from '../Table';
5
+
6
+ const originalConsoleError = console.error;
7
+ beforeEach(() => {
8
+ // Suppress console.error messages
9
+ console.error = jest.fn(originalConsoleError);
10
+ });
11
+ afterAll(() => {
12
+ // Restore console.error messages
13
+ console.error = originalConsoleError;
14
+ });
15
+
16
+ it('renders Table', () => {
17
+ render(<Table />);
18
+ const table = screen.getByRole('table');
19
+ expect(table).toBeDefined();
20
+ // Ensure no console errors
21
+ expect(console.error).not.toHaveBeenCalled();
22
+ });
23
+
24
+ it('renders complex table', () => {
25
+ render(
26
+ <Table>
27
+ <Caption>Caption</Caption>
28
+ <THead>
29
+ <TR>
30
+ <TH>Header</TH>
31
+ </TR>
32
+ </THead>
33
+ <TBody>
34
+ <TR>
35
+ <TD>Row</TD>
36
+ </TR>
37
+ </TBody>
38
+ <TFoot>
39
+ <TR>
40
+ <TD>Footer</TD>
41
+ </TR>
42
+ </TFoot>
43
+ </Table>
44
+ );
45
+ const th = screen.getByRole('columnheader');
46
+ expect(th).toBeDefined();
47
+ // Ensure no console errors
48
+ expect(console.error).not.toHaveBeenCalled();
49
+ });