@jobber/components-native 0.101.3 → 0.101.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 (182) hide show
  1. package/dist/package.json +19 -11
  2. package/dist/src/ActionItem/ActionItem.test.js +81 -0
  3. package/dist/src/ActionItem/ActionItemGroup.test.js +25 -0
  4. package/dist/src/ActionItem/components/ActionItemContainer.test.js +24 -0
  5. package/dist/src/ActionLabel/ActionLabel.test.js +81 -0
  6. package/dist/src/ActivityIndicator/ActivityIndicator.test.js +23 -0
  7. package/dist/src/AtlantisContext/AtlantisContext.test.js +35 -0
  8. package/dist/src/AtlantisThemeContext/AtlantisThemeContext.test.js +65 -0
  9. package/dist/src/AtlantisThemeContext/buildThemedStyles.test.js +43 -0
  10. package/dist/src/AutoLink/AutoLink.test.js +133 -0
  11. package/dist/src/AutoLink/components/Link/Link.test.js +18 -0
  12. package/dist/src/Banner/Banner.test.js +98 -0
  13. package/dist/src/BottomSheet/BottomSheet.test.js +105 -0
  14. package/dist/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.test.js +19 -0
  15. package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.test.js +68 -0
  16. package/dist/src/Button/Button.test.js +228 -0
  17. package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.test.js +25 -0
  18. package/dist/src/ButtonGroup/ButtonGroup.test.js +153 -0
  19. package/dist/src/Card/Card.test.js +80 -0
  20. package/dist/src/Card/components/InternalCardHeader.test.js +18 -0
  21. package/dist/src/Checkbox/Checkbox.test.js +135 -0
  22. package/dist/src/Checkbox/CheckboxGroup.test.js +197 -0
  23. package/dist/src/Checkbox/CheckboxGroupReducer.test.js +25 -0
  24. package/dist/src/Chip/Chip.test.js +69 -0
  25. package/dist/src/Content/Content.test.js +250 -0
  26. package/dist/src/ContentOverlay/ContentOverlay.test.js +297 -0
  27. package/dist/src/ContentOverlay/computeContentOverlayBehavior.test.js +197 -0
  28. package/dist/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.test.js +62 -0
  29. package/dist/src/ContentOverlay/hooks/useKeyboardVisibility.test.js +41 -0
  30. package/dist/src/ContentOverlay/hooks/useViewLayoutHeight.test.js +62 -0
  31. package/dist/src/Disclosure/Disclosure.test.js +64 -0
  32. package/dist/src/Divider/Divider.test.js +65 -0
  33. package/dist/src/EmptyState/EmptyState.test.js +82 -0
  34. package/dist/src/ErrorMessageWrapper/ErrorMessageWrapper.test.js +29 -0
  35. package/dist/src/Flex/Flex.test.js +104 -0
  36. package/dist/src/Form/Form.test.js +393 -0
  37. package/dist/src/Form/components/FormErrorBanner/FormErrorBanner.test.js +41 -0
  38. package/dist/src/Form/components/FormMessage/FormMessage.test.js +73 -0
  39. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.test.js +30 -0
  40. package/dist/src/Form/components/FormSaveButton/FormSaveButton.test.js +82 -0
  41. package/dist/src/Form/context/AtlantisFormContext.test.js +28 -0
  42. package/dist/src/Form/hooks/useScrollToError/useScrollToError.test.js +89 -0
  43. package/dist/src/FormField/FormField.test.js +81 -0
  44. package/dist/src/FormatFile/FormatFile.test.js +212 -0
  45. package/dist/src/FormatFile/FormatFileThumbnail.test.js +192 -0
  46. package/dist/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.js +74 -0
  47. package/dist/src/FormatFile/components/MediaView/MediaView.test.js +202 -0
  48. package/dist/src/FormatFile/utils/parseFile.test.js +188 -0
  49. package/dist/src/Glimmer/Glimmer.test.js +61 -0
  50. package/dist/src/Heading/Heading.test.js +61 -0
  51. package/dist/src/Icon/Icon.test.js +40 -0
  52. package/dist/src/IconButton/IconButton.test.js +38 -0
  53. package/dist/src/InputCurrency/InputCurrency.test.js +106 -0
  54. package/dist/src/InputDate/InputDate.test.js +184 -0
  55. package/dist/src/InputEmail/InputEmail.test.js +27 -0
  56. package/dist/src/InputFieldWrapper/InputFieldWrapper.test.js +279 -0
  57. package/dist/src/InputFieldWrapper/components/ClearAction/ClearAction.test.js +9 -0
  58. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.test.js +130 -0
  59. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.test.js +51 -0
  60. package/dist/src/InputNumber/InputNumber.test.js +220 -0
  61. package/dist/src/InputPassword/InputPassword.test.js +63 -0
  62. package/dist/src/InputPressable/InputPressable.test.js +138 -0
  63. package/dist/src/InputSearch/InputSearch.test.js +54 -0
  64. package/dist/src/InputText/InputText.test.js +652 -0
  65. package/dist/src/InputText/context/InputAccessoriesProvider.test.js +71 -0
  66. package/dist/src/InputTime/InputTime.test.js +199 -0
  67. package/dist/src/InputTime/utils/utils.test.js +32 -0
  68. package/dist/src/ProgressBar/ProgressBar.test.js +89 -0
  69. package/dist/src/Select/Select.test.js +183 -0
  70. package/dist/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.js +51 -0
  71. package/dist/src/Select/components/SelectInternalPicker/SelectInternalPicker.test.js +72 -0
  72. package/dist/src/StatusLabel/StatusLabel.test.js +51 -0
  73. package/dist/src/Switch/Switch.test.js +60 -0
  74. package/dist/src/Switch/components/BaseSwitch/BaseSwitch.test.js +61 -0
  75. package/dist/src/Text/Text.test.js +161 -0
  76. package/dist/src/TextList/TextList.test.js +16 -0
  77. package/dist/src/ThumbnailList/ThumbnailList.test.js +72 -0
  78. package/dist/src/Toast/Toast.test.js +51 -0
  79. package/dist/src/Typography/Typography.test.js +225 -0
  80. package/dist/src/hooks/useAtlantisI18n/useAtlantisI18n.test.js +103 -0
  81. package/dist/src/utils/meta/meta.test.js +83 -0
  82. package/dist/tsconfig.build.json +5 -1
  83. package/dist/tsconfig.build.tsbuildinfo +1 -1
  84. package/dist/tsconfig.eslint.json +14 -0
  85. package/dist/tsconfig.json +3 -4
  86. package/dist/types/src/ActionItem/ActionItem.test.d.ts +1 -0
  87. package/dist/types/src/ActionItem/ActionItemGroup.test.d.ts +1 -0
  88. package/dist/types/src/ActionItem/components/ActionItemContainer.test.d.ts +1 -0
  89. package/dist/types/src/ActionLabel/ActionLabel.test.d.ts +1 -0
  90. package/dist/types/src/ActivityIndicator/ActivityIndicator.test.d.ts +1 -0
  91. package/dist/types/src/AtlantisContext/AtlantisContext.test.d.ts +1 -0
  92. package/dist/types/src/AtlantisThemeContext/AtlantisThemeContext.test.d.ts +1 -0
  93. package/dist/types/src/AtlantisThemeContext/buildThemedStyles.test.d.ts +1 -0
  94. package/dist/types/src/AutoLink/AutoLink.test.d.ts +1 -0
  95. package/dist/types/src/AutoLink/components/Link/Link.test.d.ts +1 -0
  96. package/dist/types/src/Banner/Banner.test.d.ts +1 -0
  97. package/dist/types/src/BottomSheet/BottomSheet.test.d.ts +1 -0
  98. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.test.d.ts +1 -0
  99. package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.test.d.ts +1 -0
  100. package/dist/types/src/Button/Button.test.d.ts +1 -0
  101. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.test.d.ts +1 -0
  102. package/dist/types/src/ButtonGroup/ButtonGroup.test.d.ts +1 -0
  103. package/dist/types/src/Card/Card.test.d.ts +1 -0
  104. package/dist/types/src/Card/components/InternalCardHeader.test.d.ts +1 -0
  105. package/dist/types/src/Checkbox/Checkbox.test.d.ts +1 -0
  106. package/dist/types/src/Checkbox/CheckboxGroup.test.d.ts +1 -0
  107. package/dist/types/src/Checkbox/CheckboxGroupReducer.test.d.ts +1 -0
  108. package/dist/types/src/Chip/Chip.test.d.ts +1 -0
  109. package/dist/types/src/Content/Content.test.d.ts +1 -0
  110. package/dist/types/src/ContentOverlay/BottomSheetKeyboardAwareScrollView.d.ts +2 -1
  111. package/dist/types/src/ContentOverlay/ContentOverlay.test.d.ts +1 -0
  112. package/dist/types/src/ContentOverlay/computeContentOverlayBehavior.test.d.ts +1 -0
  113. package/dist/types/src/ContentOverlay/hooks/useBottomSheetModalBackHandler.test.d.ts +1 -0
  114. package/dist/types/src/ContentOverlay/hooks/useKeyboardVisibility.test.d.ts +1 -0
  115. package/dist/types/src/ContentOverlay/hooks/useViewLayoutHeight.test.d.ts +1 -0
  116. package/dist/types/src/Disclosure/Disclosure.test.d.ts +1 -0
  117. package/dist/types/src/Divider/Divider.test.d.ts +1 -0
  118. package/dist/types/src/EmptyState/EmptyState.test.d.ts +1 -0
  119. package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.test.d.ts +1 -0
  120. package/dist/types/src/Flex/Flex.test.d.ts +1 -0
  121. package/dist/types/src/Form/Form.test.d.ts +1 -0
  122. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.test.d.ts +1 -0
  123. package/dist/types/src/Form/components/FormMessage/FormMessage.test.d.ts +1 -0
  124. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.test.d.ts +1 -0
  125. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.test.d.ts +1 -0
  126. package/dist/types/src/Form/context/AtlantisFormContext.test.d.ts +1 -0
  127. package/dist/types/src/Form/hooks/useScrollToError/useScrollToError.test.d.ts +1 -0
  128. package/dist/types/src/FormField/FormField.test.d.ts +1 -0
  129. package/dist/types/src/FormatFile/FormatFile.test.d.ts +1 -0
  130. package/dist/types/src/FormatFile/FormatFileThumbnail.test.d.ts +1 -0
  131. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.test.d.ts +1 -0
  132. package/dist/types/src/FormatFile/components/MediaView/MediaView.test.d.ts +1 -0
  133. package/dist/types/src/FormatFile/utils/parseFile.test.d.ts +1 -0
  134. package/dist/types/src/Glimmer/Glimmer.test.d.ts +1 -0
  135. package/dist/types/src/Heading/Heading.test.d.ts +1 -0
  136. package/dist/types/src/Icon/Icon.test.d.ts +1 -0
  137. package/dist/types/src/IconButton/IconButton.test.d.ts +1 -0
  138. package/dist/types/src/InputCurrency/InputCurrency.test.d.ts +1 -0
  139. package/dist/types/src/InputDate/InputDate.test.d.ts +1 -0
  140. package/dist/types/src/InputEmail/InputEmail.test.d.ts +1 -0
  141. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.test.d.ts +1 -0
  142. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.test.d.ts +1 -0
  143. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.test.d.ts +1 -0
  144. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.test.d.ts +1 -0
  145. package/dist/types/src/InputNumber/InputNumber.test.d.ts +1 -0
  146. package/dist/types/src/InputPassword/InputPassword.test.d.ts +1 -0
  147. package/dist/types/src/InputPressable/InputPressable.test.d.ts +1 -0
  148. package/dist/types/src/InputSearch/InputSearch.test.d.ts +1 -0
  149. package/dist/types/src/InputText/InputText.test.d.ts +1 -0
  150. package/dist/types/src/InputText/context/InputAccessoriesProvider.test.d.ts +1 -0
  151. package/dist/types/src/InputTime/InputTime.test.d.ts +1 -0
  152. package/dist/types/src/InputTime/utils/utils.test.d.ts +1 -0
  153. package/dist/types/src/ProgressBar/ProgressBar.test.d.ts +1 -0
  154. package/dist/types/src/Select/Select.test.d.ts +1 -0
  155. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.test.d.ts +1 -0
  156. package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.test.d.ts +1 -0
  157. package/dist/types/src/StatusLabel/StatusLabel.test.d.ts +1 -0
  158. package/dist/types/src/Switch/Switch.test.d.ts +1 -0
  159. package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.test.d.ts +1 -0
  160. package/dist/types/src/Text/Text.test.d.ts +1 -0
  161. package/dist/types/src/TextList/TextList.test.d.ts +1 -0
  162. package/dist/types/src/ThumbnailList/ThumbnailList.test.d.ts +1 -0
  163. package/dist/types/src/Toast/Toast.test.d.ts +1 -0
  164. package/dist/types/src/Typography/Typography.test.d.ts +1 -0
  165. package/dist/types/src/hooks/useAtlantisI18n/useAtlantisI18n.test.d.ts +1 -0
  166. package/dist/types/src/utils/meta/meta.test.d.ts +1 -0
  167. package/package.json +19 -11
  168. package/src/Button/Button.test.tsx +6 -2
  169. package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +3 -3
  170. package/src/Divider/Divider.stories.tsx +1 -1
  171. package/src/Flex/Flex.test.tsx +1 -1
  172. package/src/Form/Form.test.tsx +3 -1
  173. package/src/FormField/FormField.test.tsx +5 -1
  174. package/src/Heading/__snapshots__/Heading.test.tsx.snap +1 -1
  175. package/src/InputDate/InputDate.test.tsx +7 -1
  176. package/src/InputText/InputText.test.tsx +2 -1
  177. package/src/InputTime/InputTime.test.tsx +7 -1
  178. package/src/Select/Select.test.tsx +1 -1
  179. package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +8 -8
  180. package/src/Text/__snapshots__/Text.test.tsx.snap +2 -2
  181. package/src/ThumbnailList/__snapshots__/ThumbnailList.test.tsx.snap +1 -1
  182. package/src/Typography/__snapshots__/Typography.test.tsx.snap +4 -4
@@ -0,0 +1,225 @@
1
+ import React from "react";
2
+ import { fireEvent, render } from "@testing-library/react-native";
3
+ import { I18nManager } from "react-native";
4
+ import { Typography } from "./Typography";
5
+ it("renders text with no additional props", () => {
6
+ const typography = render(React.createElement(Typography, null, "Test Text"));
7
+ expect(typography.toJSON()).toMatchSnapshot();
8
+ });
9
+ it("renders text with regular style", () => {
10
+ const typography = render(React.createElement(Typography, { fontStyle: "regular" }, "Test Text"));
11
+ expect(typography.toJSON()).toMatchSnapshot();
12
+ });
13
+ it("renders text with bold style", () => {
14
+ const typography = render(React.createElement(Typography, { fontWeight: "bold" }, "Test Text"));
15
+ expect(typography.toJSON()).toMatchSnapshot();
16
+ });
17
+ it("renders text with italic style", () => {
18
+ const typography = render(React.createElement(Typography, { fontStyle: "italic" }, "Test Text"));
19
+ expect(typography.toJSON()).toMatchSnapshot();
20
+ });
21
+ it("renders text with bold weight and italic style", () => {
22
+ const typography = render(React.createElement(Typography, { fontStyle: "italic", fontWeight: "bold" }, "Test Text"));
23
+ expect(typography.toJSON()).toMatchSnapshot();
24
+ });
25
+ it("renders text with bold style and display as fontFamily", () => {
26
+ const typography = render(React.createElement(Typography, { fontFamily: "display", fontWeight: "bold" }, "Test Text"));
27
+ expect(typography.toJSON()).toMatchSnapshot();
28
+ });
29
+ it("renders text with extraBold weight and display as fontFamily", () => {
30
+ const typography = render(React.createElement(Typography, { fontFamily: "display", fontWeight: "extraBold" }, "Test Text"));
31
+ expect(typography.toJSON()).toMatchSnapshot();
32
+ });
33
+ it("renders text with black style and display as fontFamily", () => {
34
+ const typography = render(React.createElement(Typography, { fontFamily: "display", fontWeight: "black" }, "Test Text"));
35
+ expect(typography.toJSON()).toMatchSnapshot();
36
+ });
37
+ it("renders text with uppercase transform", () => {
38
+ const typography = render(React.createElement(Typography, { transform: "uppercase" }, "Test Text"));
39
+ expect(typography.toJSON()).toMatchSnapshot();
40
+ });
41
+ it("renders text with lowercase transform", () => {
42
+ const typography = render(React.createElement(Typography, { transform: "lowercase" }, "Test Text"));
43
+ expect(typography.toJSON()).toMatchSnapshot();
44
+ });
45
+ it("supports nested children and applies transform only to string children", () => {
46
+ const typography = render(React.createElement(Typography, { transform: "uppercase" },
47
+ "before ",
48
+ React.createElement(Typography, { fontWeight: "bold" }, "Inner"),
49
+ " after"));
50
+ expect(typography.toJSON()).toMatchSnapshot();
51
+ });
52
+ it("allows child Typography to control its own transform", () => {
53
+ const view = render(React.createElement(Typography, { transform: "uppercase" },
54
+ "before ",
55
+ React.createElement(Typography, { fontWeight: "bold", transform: "lowercase" }, "Inner"),
56
+ " after")).toJSON();
57
+ expect(view).toMatchSnapshot();
58
+ });
59
+ it("supports multi-level nesting across Typography and Text", () => {
60
+ const view = render(React.createElement(Typography, { transform: "uppercase" },
61
+ "level1 ",
62
+ React.createElement(Typography, null,
63
+ "and ",
64
+ React.createElement(Typography, { transform: "lowercase" }, "INNER")),
65
+ " end")).toJSON();
66
+ expect(view).toMatchSnapshot();
67
+ });
68
+ it("applies transform to parent strings only", () => {
69
+ const { getByText } = render(React.createElement(Typography, { transform: "uppercase" },
70
+ "test ",
71
+ React.createElement(Typography, null, "inner")));
72
+ expect(getByText(/TEST/)).toBeDefined();
73
+ expect(getByText("inner")).toBeDefined();
74
+ });
75
+ it("allows child transform to override parent transform", () => {
76
+ const { getByText } = render(React.createElement(Typography, { transform: "uppercase" },
77
+ "before ",
78
+ React.createElement(Typography, { transform: "lowercase" }, "INNER"),
79
+ " after"));
80
+ expect(getByText(/BEFORE/)).toBeDefined();
81
+ expect(getByText("inner")).toBeDefined();
82
+ expect(getByText(/AFTER/)).toBeDefined();
83
+ });
84
+ it("renders text with white color", () => {
85
+ const typography = render(React.createElement(Typography, { color: "white" }, "Test Text"));
86
+ expect(typography.toJSON()).toMatchSnapshot();
87
+ });
88
+ it("renders text with green color", () => {
89
+ const typography = render(React.createElement(Typography, { color: "green" }, "Test Text"));
90
+ expect(typography.toJSON()).toMatchSnapshot();
91
+ });
92
+ it("renders text with semantic color", () => {
93
+ const typography = render(React.createElement(Typography, { color: "inactiveOnSurface" }, "Test Text"));
94
+ expect(typography.toJSON()).toMatchSnapshot();
95
+ });
96
+ it("renders text with default color", () => {
97
+ const typography = render(React.createElement(Typography, { color: "default" }, "Test Text"));
98
+ expect(typography.toJSON()).toMatchSnapshot();
99
+ });
100
+ it("renders text with center align", () => {
101
+ const typography = render(React.createElement(Typography, { align: "center" }, "Test Text"));
102
+ expect(typography.toJSON()).toMatchSnapshot();
103
+ });
104
+ it("renders text respecting the text direction", () => {
105
+ I18nManager.isRTL = true;
106
+ const typography = render(React.createElement(Typography, null, "Test Text"));
107
+ expect(typography.toJSON()).toMatchSnapshot();
108
+ I18nManager.isRTL = false;
109
+ });
110
+ it("renders text with small size", () => {
111
+ const typography = render(React.createElement(Typography, { size: "small" }, "Test Text"));
112
+ expect(typography.toJSON()).toMatchSnapshot();
113
+ });
114
+ it("renders text with large size", () => {
115
+ const typography = render(React.createElement(Typography, { size: "large" }, "Test Text"));
116
+ expect(typography.toJSON()).toMatchSnapshot();
117
+ });
118
+ it("renders text with default size", () => {
119
+ const typography = render(React.createElement(Typography, { size: "default" }, "Test Text"));
120
+ expect(typography.toJSON()).toMatchSnapshot();
121
+ });
122
+ it("renders text with multiple properties", () => {
123
+ const typography = render(React.createElement(Typography, { fontWeight: "bold", size: "large", color: "white" }, "Test Text"));
124
+ expect(typography.toJSON()).toMatchSnapshot();
125
+ });
126
+ it("renders text with line height override", () => {
127
+ const typography = render(React.createElement(Typography, { lineHeight: "jumbo" }, "Test Text"));
128
+ expect(typography.toJSON()).toMatchSnapshot();
129
+ });
130
+ it("renders text with letter spacing", () => {
131
+ const typography = render(React.createElement(Typography, { letterSpacing: "loose" }, "Test Text"));
132
+ expect(typography.toJSON()).toMatchSnapshot();
133
+ });
134
+ it("renders text with reverseTheme true with reversible color", () => {
135
+ const typography = render(React.createElement(Typography, { reverseTheme: true, color: "success" }, "Test Text"));
136
+ expect(typography.toJSON()).toMatchSnapshot();
137
+ });
138
+ it("renders text with reverseTheme false with reversible color", () => {
139
+ const typography = render(React.createElement(Typography, { reverseTheme: false, color: "success" }, "Test Text"));
140
+ expect(typography.toJSON()).toMatchSnapshot();
141
+ });
142
+ it("renders text with adjustsFontSizeToFit set to true", () => {
143
+ const typography = render(React.createElement(Typography, { adjustsFontSizeToFit: true, maxLines: "single" }, "Test Text that happens to be longer than the rest of the text. This just keeps going on and on. maxLines being set will make this work its magic"));
144
+ expect(typography.toJSON()).toMatchSnapshot();
145
+ });
146
+ it("renders text accessibilityRole", () => {
147
+ const typography = render(React.createElement(Typography, { accessibilityRole: "text" }, "Test Text"));
148
+ expect(typography.getByRole("text")).toBeDefined();
149
+ });
150
+ it("renders header accessibilityRole", () => {
151
+ const typography = render(React.createElement(Typography, { accessibilityRole: "header" }, "Test Text"));
152
+ expect(typography.getByRole("header")).toBeDefined();
153
+ });
154
+ it("renders text using the maxLines is also passed", () => {
155
+ const typography = render(React.createElement(Typography, { maxLines: "small" }, "Test Text that happens to be longer than the rest of the text. This just keeps going on and on. maxLines being set will make this work its magic"));
156
+ expect(typography.toJSON()).toMatchSnapshot();
157
+ });
158
+ it("renders text with strikethough styling", () => {
159
+ const typography = render(React.createElement(Typography, { strikeThrough: true }, "Test Text"));
160
+ expect(typography.toJSON()).toMatchSnapshot();
161
+ });
162
+ it("renders text that is inaccessible", () => {
163
+ const typography = render(React.createElement(Typography, { hideFromScreenReader: true }, "Test Text"));
164
+ expect(typography.root.props).toEqual(expect.objectContaining({
165
+ accessible: false,
166
+ accessibilityRole: "none",
167
+ importantForAccessibility: "no-hide-descendants",
168
+ }));
169
+ });
170
+ it("applies custom UNSAFE_style to text", () => {
171
+ const customStyle = { color: "red", fontSize: 20 };
172
+ const typography = render(React.createElement(Typography, { UNSAFE_style: { textStyle: customStyle } }, "Test Text"));
173
+ const textElement = typography.getByText("Test Text");
174
+ expect(textElement.props.style).toEqual(expect.arrayContaining([expect.objectContaining(customStyle)]));
175
+ });
176
+ describe("underline", () => {
177
+ it.each(["solid", "double", "dotted", "dashed"])("renders text with %s underline", underlineStyle => {
178
+ const typography = render(React.createElement(Typography, { underline: underlineStyle }, "Test Text"));
179
+ expect(typography.toJSON()).toMatchSnapshot();
180
+ });
181
+ });
182
+ describe("onTextLayout", () => {
183
+ it("calls onTextLayout callback when text layout event occurs", () => {
184
+ const onTextLayoutMock = jest.fn();
185
+ const { getByRole } = render(React.createElement(Typography, { onTextLayout: onTextLayoutMock }, "Test Text"));
186
+ const textElement = getByRole("text");
187
+ const mockEvent = {
188
+ nativeEvent: {
189
+ lines: [
190
+ {
191
+ text: "Test Text",
192
+ x: 0,
193
+ y: 0,
194
+ width: 100,
195
+ height: 20,
196
+ ascender: 15,
197
+ descender: -5,
198
+ capHeight: 14,
199
+ xHeight: 10,
200
+ },
201
+ ],
202
+ },
203
+ };
204
+ fireEvent(textElement, "onTextLayout", mockEvent);
205
+ expect(onTextLayoutMock).toHaveBeenCalledTimes(1);
206
+ expect(onTextLayoutMock).toHaveBeenCalledWith(mockEvent);
207
+ });
208
+ });
209
+ describe("TypographyGestureDetector", () => {
210
+ it("wraps text with TypographyGestureDetector by default (collapsable=false)", () => {
211
+ const { getByRole } = render(React.createElement(Typography, null, "Test Text"));
212
+ const textElement = getByRole("text");
213
+ expect(textElement.props.collapsable).toBe(false);
214
+ });
215
+ it("wraps text with TypographyGestureDetector (collapsable=false) when selectable=true", () => {
216
+ const { getByRole } = render(React.createElement(Typography, { selectable: true }, "Test Text"));
217
+ const textElement = getByRole("text");
218
+ expect(textElement.props.collapsable).toBe(false);
219
+ });
220
+ it("does not wrap text with TypographyGestureDetector when selectable=false", () => {
221
+ const { getByRole } = render(React.createElement(Typography, { selectable: false }, "Test Text"));
222
+ const textElement = getByRole("text");
223
+ expect(textElement.props.collapsable).toBeUndefined();
224
+ });
225
+ });
@@ -0,0 +1,103 @@
1
+ import { renderHook } from "@testing-library/react-native";
2
+ import { useAtlantisI18n } from ".";
3
+ import en from "./locales/en.json";
4
+ import es from "./locales/es.json";
5
+ import * as context from "../../AtlantisContext";
6
+ jest.mock("../../AtlantisContext", () => (Object.assign({
7
+ // need to mark this as a module so that we can spy on it
8
+ __esModule: true }, jest.requireActual("../../AtlantisContext"))));
9
+ const spy = jest.spyOn(context, "useAtlantisContext");
10
+ const testDate = new Date("2020-01-01T00:00:00.000Z");
11
+ const dateAfterSpringForward = new Date("2020-04-10T00:00:00.000Z");
12
+ beforeEach(() => {
13
+ jest.useFakeTimers();
14
+ jest.setSystemTime(testDate);
15
+ });
16
+ describe("useAtlantisI18n", () => {
17
+ it("should return english by default", () => {
18
+ const { result } = renderHook(useAtlantisI18n);
19
+ expect(result.current.t("cancel")).toBe("Cancel");
20
+ });
21
+ it("should interpolate the strings wrapped in {}", () => {
22
+ const { result } = renderHook(useAtlantisI18n);
23
+ expect(result.current.t("FormatFile.preview", { item: "🔱" })).toBe("Preview 🔱");
24
+ });
25
+ describe("Español", () => {
26
+ it("should return español", () => {
27
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
28
+ const { result } = renderHook(useAtlantisI18n);
29
+ expect(result.current.t("cancel")).toBe("Cancelar");
30
+ });
31
+ });
32
+ describe("Unsupported language", () => {
33
+ it("should return the english translation", () => {
34
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "fr" }));
35
+ const { result } = renderHook(useAtlantisI18n);
36
+ expect(result.current.t("cancel")).toBe("Cancel");
37
+ });
38
+ });
39
+ describe("Translation files", () => {
40
+ it("should have the same keys for en and es", () => {
41
+ expect(Object.keys(en)).toEqual(Object.keys(es));
42
+ });
43
+ });
44
+ describe("formatDate", () => {
45
+ it("should return the formatted date", () => {
46
+ const { result } = renderHook(useAtlantisI18n);
47
+ expect(result.current.formatDate(testDate)).toBe("Jan 1, 2020");
48
+ });
49
+ it("should return the date formatted for es", () => {
50
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
51
+ const { result } = renderHook(useAtlantisI18n);
52
+ expect(result.current.formatDate(testDate)).toBe("1 ene 2020");
53
+ });
54
+ describe("Timezone", () => {
55
+ it.each([
56
+ ["America/New_York", "Dec 31, 2019"],
57
+ ["America/Chicago", "Dec 31, 2019"],
58
+ ["America/Denver", "Dec 31, 2019"],
59
+ ["Europe/London", "Jan 1, 2020"],
60
+ ["Australia/Sydney", "Jan 1, 2020"],
61
+ ])("should return the %s time", (timeZone, expected) => {
62
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { timeZone }));
63
+ const { result } = renderHook(useAtlantisI18n);
64
+ expect(result.current.formatDate(testDate)).toBe(expected);
65
+ });
66
+ });
67
+ });
68
+ describe("formatTime", () => {
69
+ it("should return the formatted time", () => {
70
+ const { result } = renderHook(useAtlantisI18n);
71
+ expect(result.current.formatTime(testDate)).toBe("12:00 AM");
72
+ });
73
+ it("should return the date formatted for es", () => {
74
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { locale: "es" }));
75
+ const { result } = renderHook(useAtlantisI18n);
76
+ expect(result.current.formatTime(testDate)).toBe("00:00");
77
+ });
78
+ describe("Timezone", () => {
79
+ it.each([
80
+ ["America/New_York", "7:00 PM"],
81
+ ["America/Chicago", "6:00 PM"],
82
+ ["America/Denver", "5:00 PM"],
83
+ ["Europe/London", "12:00 AM"],
84
+ ["Australia/Sydney", "11:00 AM"],
85
+ ])("should return the %s zoned time", (timeZone, expected) => {
86
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { timeZone }));
87
+ const { result } = renderHook(useAtlantisI18n);
88
+ expect(result.current.formatTime(testDate)).toBe(expected);
89
+ });
90
+ it.each([
91
+ ["America/New_York", "8:00 PM"],
92
+ ["America/Chicago", "7:00 PM"],
93
+ ["America/Denver", "6:00 PM"],
94
+ ["Europe/London", "1:00 AM"],
95
+ ["Australia/Sydney", "10:00 AM"],
96
+ ])("should return the %s spring zoned time", (timeZone, expected) => {
97
+ spy.mockReturnValueOnce(Object.assign(Object.assign({}, context.atlantisContextDefaultValues), { timeZone }));
98
+ const { result } = renderHook(useAtlantisI18n);
99
+ expect(result.current.formatTime(dateAfterSpringForward)).toBe(expected);
100
+ });
101
+ });
102
+ });
103
+ });
@@ -0,0 +1,83 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import * as fs from "fs/promises";
11
+ import * as allExports from "../../index";
12
+ jest.mock("../../AutoLink/clipboard", () => {
13
+ return {
14
+ copyTextToClipboard: jest.fn(),
15
+ };
16
+ });
17
+ describe("meta", () => {
18
+ // If this test fails, please update meta.json accordingly.
19
+ it("verifies that the meta.json file is up to date", () => __awaiter(void 0, void 0, void 0, function* () {
20
+ const meta = yield fs.readFile(`${__dirname}/meta.json`, "utf-8");
21
+ const allNames = findComponentNamesDeep(allExports);
22
+ allNames.sort();
23
+ expect(JSON.parse(meta)).toStrictEqual({
24
+ exportedComponents: allNames,
25
+ });
26
+ }));
27
+ });
28
+ // NOTE: Keep this in sync with components/src/utils/meta/meta.test.tsx
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ function isComponent(name, value) {
31
+ const isFirstLetterUppercase = /^[A-Z]/.test(name);
32
+ const isFunctionComponent = typeof value === "function";
33
+ return isFirstLetterUppercase && isFunctionComponent;
34
+ }
35
+ // NOTE: Keep this in sync with components/src/utils/meta/meta.test.tsx
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ function isContext(value) {
38
+ return (value &&
39
+ typeof value === "object" &&
40
+ Object.prototype.hasOwnProperty.call(value, "Provider") &&
41
+ Object.prototype.hasOwnProperty.call(value, "Consumer"));
42
+ }
43
+ // NOTE: Keep this in sync with components/src/utils/meta/meta.test.tsx
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ function isForwardedRef(name, value) {
46
+ const isFirstLetterUppercase = /^[A-Z]/.test(name);
47
+ return (isFirstLetterUppercase &&
48
+ value &&
49
+ typeof value === "object" &&
50
+ typeof value.render === "function");
51
+ }
52
+ // NOTE: Keep this in sync with components/src/utils/meta/meta.test.tsx
53
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ function isMemoizedComponent(name, value) {
55
+ const isFirstLetterUppercase = /^[A-Z]/.test(name);
56
+ return (isFirstLetterUppercase &&
57
+ value &&
58
+ typeof value === "object" &&
59
+ typeof value.$$typeof === "symbol" &&
60
+ value.$$typeof.toString() === "Symbol(react.memo)" &&
61
+ typeof value.type === "function");
62
+ }
63
+ // NOTE: Keep this in sync with components/src/utils/meta/meta.test.tsx
64
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
65
+ function findComponentNamesDeep(objectOrFunction, name) {
66
+ const entries = [...Object.entries(objectOrFunction)];
67
+ return entries.reduce((allNames, [k, v]) => {
68
+ if (isContext(v)) {
69
+ allNames.push(`${k}.Provider`, `${k}.Consumer`);
70
+ }
71
+ else if (isForwardedRef(k, v) || isMemoizedComponent(k, v)) {
72
+ const thisName = name ? `${name}.${k}` : k;
73
+ allNames.push(thisName);
74
+ }
75
+ else if (isComponent(k, v)) {
76
+ const thisName = name ? `${name}.${k}` : k;
77
+ allNames.push(thisName);
78
+ const childComponents = findComponentNamesDeep(v, k);
79
+ allNames.push(...childComponents);
80
+ }
81
+ return allNames;
82
+ }, []);
83
+ }
@@ -3,5 +3,9 @@
3
3
  "compilerOptions": {
4
4
  // Exclude "@jobber/hooks" from paths to avoid building hooks from src
5
5
  "paths": {}
6
- }
6
+ },
7
+ "exclude": [
8
+ "*.test.*",
9
+ "**/*.stories.tsx"
10
+ ]
7
11
  }