@jobber/components-native 0.2.0 → 0.3.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.
@@ -0,0 +1,219 @@
1
+ import React from "react";
2
+ import { render } from "@testing-library/react-native";
3
+ import { I18nManager } from "react-native";
4
+ import { Typography } from "./Typography";
5
+
6
+ it("renders text with no additional props", () => {
7
+ const typography = render(<Typography>Test Text</Typography>);
8
+ expect(typography.toJSON()).toMatchSnapshot();
9
+ });
10
+
11
+ it("renders text with regular style", () => {
12
+ const typography = render(
13
+ <Typography fontStyle="regular">Test Text</Typography>,
14
+ );
15
+ expect(typography.toJSON()).toMatchSnapshot();
16
+ });
17
+
18
+ it("renders text with bold style", () => {
19
+ const typography = render(
20
+ <Typography fontWeight="bold">Test Text</Typography>,
21
+ );
22
+ expect(typography.toJSON()).toMatchSnapshot();
23
+ });
24
+
25
+ it("renders text with italic style", () => {
26
+ const typography = render(
27
+ <Typography fontStyle="italic">Test Text</Typography>,
28
+ );
29
+ expect(typography.toJSON()).toMatchSnapshot();
30
+ });
31
+
32
+ it("renders text with bold weight and italic style", () => {
33
+ const typography = render(
34
+ <Typography fontStyle="italic" fontWeight="bold">
35
+ Test Text
36
+ </Typography>,
37
+ );
38
+ expect(typography.toJSON()).toMatchSnapshot();
39
+ });
40
+
41
+ it("renders text with bold style and display as fontFamily", () => {
42
+ const typography = render(
43
+ <Typography fontFamily="display" fontWeight="bold">
44
+ Test Text
45
+ </Typography>,
46
+ );
47
+ expect(typography.toJSON()).toMatchSnapshot();
48
+ });
49
+
50
+ it("renders text with extraBold weight and display as fontFamily", () => {
51
+ const typography = render(
52
+ <Typography fontFamily="display" fontWeight="extraBold">
53
+ Test Text
54
+ </Typography>,
55
+ );
56
+ expect(typography.toJSON()).toMatchSnapshot();
57
+ });
58
+
59
+ it("renders text with black style and display as fontFamily", () => {
60
+ const typography = render(
61
+ <Typography fontFamily="display" fontWeight="black">
62
+ Test Text
63
+ </Typography>,
64
+ );
65
+ expect(typography.toJSON()).toMatchSnapshot();
66
+ });
67
+
68
+ it("renders text with uppercase transform", () => {
69
+ const typography = render(
70
+ <Typography transform="uppercase">Test Text</Typography>,
71
+ );
72
+ expect(typography.toJSON()).toMatchSnapshot();
73
+ });
74
+
75
+ it("renders text with lowercase transform", () => {
76
+ const typography = render(
77
+ <Typography transform="lowercase">Test Text</Typography>,
78
+ );
79
+ expect(typography.toJSON()).toMatchSnapshot();
80
+ });
81
+
82
+ it("renders text with white color", () => {
83
+ const typography = render(<Typography color="white">Test Text</Typography>);
84
+ expect(typography.toJSON()).toMatchSnapshot();
85
+ });
86
+
87
+ it("renders text with green color", () => {
88
+ const typography = render(<Typography color="green">Test Text</Typography>);
89
+ expect(typography.toJSON()).toMatchSnapshot();
90
+ });
91
+
92
+ it("renders text with default color", () => {
93
+ const typography = render(<Typography color="default">Test Text</Typography>);
94
+ expect(typography.toJSON()).toMatchSnapshot();
95
+ });
96
+
97
+ it("renders text with center align", () => {
98
+ const typography = render(<Typography align="center">Test Text</Typography>);
99
+ expect(typography.toJSON()).toMatchSnapshot();
100
+ });
101
+
102
+ it("renders text respecting the text direction", () => {
103
+ I18nManager.isRTL = true;
104
+
105
+ const typography = render(<Typography>Test Text</Typography>);
106
+ expect(typography.toJSON()).toMatchSnapshot();
107
+ I18nManager.isRTL = false;
108
+ });
109
+
110
+ it("renders text with small size", () => {
111
+ const typography = render(<Typography size="small">Test Text</Typography>);
112
+ expect(typography.toJSON()).toMatchSnapshot();
113
+ });
114
+
115
+ it("renders text with large size", () => {
116
+ const typography = render(<Typography size="large">Test Text</Typography>);
117
+ expect(typography.toJSON()).toMatchSnapshot();
118
+ });
119
+
120
+ it("renders text with default size", () => {
121
+ const typography = render(<Typography size="default">Test Text</Typography>);
122
+ expect(typography.toJSON()).toMatchSnapshot();
123
+ });
124
+
125
+ it("renders text with multiple properties", () => {
126
+ const typography = render(
127
+ <Typography fontWeight="bold" size="large" color="white">
128
+ Test Text
129
+ </Typography>,
130
+ );
131
+ expect(typography.toJSON()).toMatchSnapshot();
132
+ });
133
+
134
+ it("renders text with line height override", () => {
135
+ const typography = render(
136
+ <Typography lineHeight="jumbo">Test Text</Typography>,
137
+ );
138
+ expect(typography.toJSON()).toMatchSnapshot();
139
+ });
140
+
141
+ it("renders text with letter spacing", () => {
142
+ const typography = render(
143
+ <Typography letterSpacing="loose">Test Text</Typography>,
144
+ );
145
+ expect(typography.toJSON()).toMatchSnapshot();
146
+ });
147
+
148
+ it("renders text with reverseTheme true with reversible color", () => {
149
+ const typography = render(
150
+ <Typography reverseTheme={true} color="success">
151
+ Test Text
152
+ </Typography>,
153
+ );
154
+ expect(typography.toJSON()).toMatchSnapshot();
155
+ });
156
+
157
+ it("renders text with reverseTheme false with reversible color", () => {
158
+ const typography = render(
159
+ <Typography reverseTheme={false} color="success">
160
+ Test Text
161
+ </Typography>,
162
+ );
163
+ expect(typography.toJSON()).toMatchSnapshot();
164
+ });
165
+
166
+ it("renders text with adjustsFontSizeToFit set to true", () => {
167
+ const typography = render(
168
+ <Typography adjustsFontSizeToFit={true} maxLines="single">
169
+ Test Text that happens to be longer than the rest of the text. This just
170
+ keeps going on and on. maxLines being set will make this work its magic
171
+ </Typography>,
172
+ );
173
+ expect(typography.toJSON()).toMatchSnapshot();
174
+ });
175
+
176
+ it("renders text accessibilityRole", () => {
177
+ const typography = render(
178
+ <Typography accessibilityRole="text">Test Text</Typography>,
179
+ );
180
+ expect(typography.getByRole("text")).toBeDefined();
181
+ });
182
+
183
+ it("renders header accessibilityRole", () => {
184
+ const typography = render(
185
+ <Typography accessibilityRole="header">Test Text</Typography>,
186
+ );
187
+ expect(typography.getByRole("header")).toBeDefined();
188
+ });
189
+
190
+ it("renders text using the maxLines is also passed", () => {
191
+ const typography = render(
192
+ <Typography maxLines="small">
193
+ Test Text that happens to be longer than the rest of the text. This just
194
+ keeps going on and on. maxLines being set will make this work its magic
195
+ </Typography>,
196
+ );
197
+ expect(typography.toJSON()).toMatchSnapshot();
198
+ });
199
+
200
+ it("renders text with strikethough styling", () => {
201
+ const typography = render(
202
+ <Typography strikeThrough={true}>Test Text</Typography>,
203
+ );
204
+ expect(typography.toJSON()).toMatchSnapshot();
205
+ });
206
+
207
+ it("renders text that is inaccessible", () => {
208
+ const typography = render(
209
+ <Typography hideFromScreenReader={true}>Test Text</Typography>,
210
+ );
211
+
212
+ expect(typography.root.props).toEqual(
213
+ expect.objectContaining({
214
+ accessible: false,
215
+ accessibilityRole: "none",
216
+ importantForAccessibility: "no-hide-descendants",
217
+ }),
218
+ );
219
+ });