@feminab/box-ui 0.1.0 โ†’ 0.1.2

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 (188) hide show
  1. package/.storybook/main.ts +40 -2
  2. package/dist/@interfaces/Badge.d.d.ts.map +1 -1
  3. package/dist/@interfaces/Button.d.d.ts.map +1 -1
  4. package/dist/@interfaces/Color.d.d.ts.map +1 -1
  5. package/dist/@interfaces/IButtonItem.d.d.ts.map +1 -1
  6. package/dist/@interfaces/ISubNavItem.d.d.ts.map +1 -1
  7. package/dist/@interfaces/MobileNavProps.d.d.ts.map +1 -1
  8. package/dist/@interfaces/NavItem.d.d.ts.map +1 -1
  9. package/dist/@interfaces/Pagination.d.d.ts.map +1 -1
  10. package/dist/@interfaces/Select.d.d.ts.map +1 -1
  11. package/dist/@interfaces/SideNavProps.d.d.ts.map +1 -1
  12. package/dist/@interfaces/TextInput.d.d.ts.map +1 -1
  13. package/dist/@interfaces/index.d.ts.map +1 -1
  14. package/dist/Badge.d.ts.map +1 -1
  15. package/dist/Button.d.ts.map +1 -1
  16. package/dist/ButtonGroup.d.ts.map +1 -1
  17. package/dist/ColorBox.d.ts.map +1 -1
  18. package/dist/Header.d.ts.map +1 -1
  19. package/dist/Nav/MobileNav.d.ts.map +1 -1
  20. package/dist/Nav/NavItem.d.ts.map +1 -1
  21. package/dist/Nav/SideNav.d.ts.map +1 -1
  22. package/dist/Nav/SubNavItem.d.ts.map +1 -1
  23. package/dist/Paginate.d.ts.map +1 -1
  24. package/dist/Select.d.ts.map +1 -1
  25. package/dist/StoryLayout.d.ts.map +1 -1
  26. package/dist/TextInput.d.ts.map +1 -1
  27. package/dist/Typography.d.ts.map +1 -1
  28. package/dist/box-ui.cjs.development.js +17 -11
  29. package/dist/box-ui.cjs.development.js.map +1 -1
  30. package/dist/box-ui.cjs.production.min.js +1 -1
  31. package/dist/box-ui.cjs.production.min.js.map +1 -1
  32. package/dist/box-ui.esm.js +17 -11
  33. package/dist/box-ui.esm.js.map +1 -1
  34. package/dist/data/colors.d.ts.map +1 -1
  35. package/dist/data/countries.d.ts.map +1 -1
  36. package/dist/data/images/index.d.ts.map +1 -1
  37. package/dist/data/index.d.ts.map +1 -1
  38. package/dist/data/navItems.d.ts.map +1 -1
  39. package/dist/data/options.d.ts.map +1 -1
  40. package/dist/data/prices.d.ts.map +1 -1
  41. package/dist/hooks/useIconClassName.d.ts.map +1 -1
  42. package/dist/hooks/useIconProps.d.ts.map +1 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/jest.config.d.ts +9 -0
  45. package/dist/jest.config.d.ts.map +1 -0
  46. package/dist/reportWebVitals.d.ts.map +1 -1
  47. package/dist/setupTests.d.ts.map +1 -1
  48. package/dist/stories/Badge.stories.d.ts +3 -4
  49. package/dist/stories/Badge.stories.d.ts.map +1 -1
  50. package/dist/stories/Button.stories.d.ts +3 -4
  51. package/dist/stories/Button.stories.d.ts.map +1 -1
  52. package/dist/stories/ButtonGroup.stories.d.ts +4 -4
  53. package/dist/stories/ButtonGroup.stories.d.ts.map +1 -1
  54. package/dist/stories/Colors.stories.d.ts +3 -3
  55. package/dist/stories/Colors.stories.d.ts.map +1 -1
  56. package/dist/stories/MobileNav.stories.d.ts +3 -4
  57. package/dist/stories/MobileNav.stories.d.ts.map +1 -1
  58. package/dist/stories/Paginate.stories.d.ts +3 -4
  59. package/dist/stories/Paginate.stories.d.ts.map +1 -1
  60. package/dist/stories/Select.stories.d.ts +3 -4
  61. package/dist/stories/Select.stories.d.ts.map +1 -1
  62. package/dist/stories/SideNav.stories.d.ts +3 -4
  63. package/dist/stories/SideNav.stories.d.ts.map +1 -1
  64. package/dist/stories/TextInput.stories.d.ts +3 -4
  65. package/dist/stories/TextInput.stories.d.ts.map +1 -1
  66. package/dist/stories/Typography.stories.d.ts +4 -4
  67. package/dist/stories/Typography.stories.d.ts.map +1 -1
  68. package/dist/utils/IconWrapper.d.ts +8 -0
  69. package/dist/utils/IconWrapper.d.ts.map +1 -0
  70. package/jest.config.js +13 -0
  71. package/jest.setup.ts +3 -0
  72. package/netlify.toml +3 -0
  73. package/package.json +24 -26
  74. package/src/Nav/MobileNav.tsx +2 -0
  75. package/src/Nav/SideNav.tsx +1 -0
  76. package/src/Paginate.tsx +2 -0
  77. package/src/Select.tsx +1 -1
  78. package/src/TextInput.tsx +23 -27
  79. package/src/index.js +1 -1
  80. package/src/stories/Badge.stories.tsx +6 -8
  81. package/src/stories/Button.stories.tsx +21 -8
  82. package/src/stories/ButtonGroup.stories.tsx +48 -48
  83. package/src/stories/Colors.stories.tsx +2 -4
  84. package/src/stories/MobileNav.stories.tsx +29 -19
  85. package/src/stories/Paginate.stories.tsx +36 -35
  86. package/src/stories/Select.stories.tsx +46 -43
  87. package/src/stories/SideNav.stories.tsx +18 -19
  88. package/src/stories/TextInput.stories.tsx +81 -71
  89. package/src/stories/Typography.stories.tsx +2 -4
  90. package/src/styles/global.css +1 -181
  91. package/src/tests/Badge.test.tsx +48 -0
  92. package/src/tests/Button.test.tsx +69 -0
  93. package/src/tests/ButtonGroup.test.tsx +51 -0
  94. package/src/tests/MobileNav.test.tsx +66 -0
  95. package/src/tests/Paginate.test.tsx +86 -0
  96. package/src/tests/Select.test.tsx +63 -0
  97. package/src/tests/SideNav.test.tsx +43 -0
  98. package/src/tests/TextInput.test.tsx +42 -0
  99. package/src/tests/Typography.test.tsx +41 -0
  100. package/src/tests/__snapshots__/Badge.test.tsx.snap +13 -0
  101. package/src/tests/__snapshots__/Button.test.tsx.snap +106 -0
  102. package/src/tests/__snapshots__/ButtonGroup.test.tsx.snap +228 -0
  103. package/src/tests/__snapshots__/Paginate.test.tsx.snap +580 -0
  104. package/src/tests/__snapshots__/Select.test.tsx.snap +119 -0
  105. package/src/tests/__snapshots__/TextInput.test.tsx.snap +323 -0
  106. package/src/utils/IconWrapper.tsx +11 -0
  107. package/storybook-static/{125.65b26339.iframe.bundle.js โ†’ 125.df7cc93e.iframe.bundle.js} +3 -3
  108. package/storybook-static/125.df7cc93e.iframe.bundle.js.map +1 -0
  109. package/storybook-static/13.d4c3993e.iframe.bundle.js +2 -0
  110. package/storybook-static/161.f5193502.iframe.bundle.js +2 -0
  111. package/storybook-static/167.89fa6ac2.iframe.bundle.js +1 -0
  112. package/storybook-static/294.eccdc80d.iframe.bundle.js +1 -0
  113. package/storybook-static/314.c9f9245e.iframe.bundle.js +2 -0
  114. package/storybook-static/364.1cfcaebe.iframe.bundle.js +1 -0
  115. package/storybook-static/735.c396ee77.iframe.bundle.js +2 -0
  116. package/storybook-static/742.52c662a4.iframe.bundle.js +1 -0
  117. package/storybook-static/{844.aec20bdb.iframe.bundle.js โ†’ 844.3bb89aad.iframe.bundle.js} +3 -3
  118. package/storybook-static/844.3bb89aad.iframe.bundle.js.map +1 -0
  119. package/storybook-static/936.c827da74.iframe.bundle.js +1 -0
  120. package/storybook-static/961.c3df469f.iframe.bundle.js +2 -0
  121. package/storybook-static/iframe.html +3 -3
  122. package/storybook-static/main.179173d1.iframe.bundle.js +1 -0
  123. package/storybook-static/project.json +1 -1
  124. package/storybook-static/{runtime~main.295ddda4.iframe.bundle.js โ†’ runtime~main.70344601.iframe.bundle.js} +1 -1
  125. package/storybook-static/static/css/main.08036cd2.css.map +1 -1
  126. package/storybook-static/stories-Badge-stories.a924d6d5.iframe.bundle.js +1 -0
  127. package/storybook-static/stories-Button-stories.a3c88a14.iframe.bundle.js +1 -0
  128. package/storybook-static/stories-ButtonGroup-stories.2c74e4c4.iframe.bundle.js +1 -0
  129. package/storybook-static/stories-Colors-stories.424256b4.iframe.bundle.js +2 -0
  130. package/storybook-static/stories-Configure-mdx.46ebbf59.iframe.bundle.js +1 -0
  131. package/storybook-static/stories-Header-stories.df09e844.iframe.bundle.js +2 -0
  132. package/storybook-static/stories-MobileNav-stories.eb9a0ca6.iframe.bundle.js +1 -0
  133. package/storybook-static/stories-Page-stories.ab66c885.iframe.bundle.js +2 -0
  134. package/storybook-static/stories-Paginate-stories.086f736a.iframe.bundle.js +1 -0
  135. package/storybook-static/stories-Select-stories.4c04edb3.iframe.bundle.js +1 -0
  136. package/storybook-static/stories-SideNav-stories.272a4362.iframe.bundle.js +1 -0
  137. package/storybook-static/stories-TextInput-stories.cfa81131.iframe.bundle.js +1 -0
  138. package/storybook-static/stories-Typography-stories.a31da7ce.iframe.bundle.js +2 -0
  139. package/tailwind.config.js +1 -1
  140. package/tsconfig.json +6 -3
  141. package/tsdx.config.js +14 -0
  142. package/dist/Page.d.ts +0 -3
  143. package/dist/Page.d.ts.map +0 -1
  144. package/dist/stories/Header.stories.d.ts +0 -20
  145. package/dist/stories/Header.stories.d.ts.map +0 -1
  146. package/dist/stories/Page.stories.d.ts +0 -14
  147. package/dist/stories/Page.stories.d.ts.map +0 -1
  148. package/src/Page.tsx +0 -72
  149. package/src/stories/Configure.mdx +0 -364
  150. package/src/stories/Header.stories.ts +0 -33
  151. package/src/stories/Page.stories.ts +0 -32
  152. package/storybook-static/125.65b26339.iframe.bundle.js.map +0 -1
  153. package/storybook-static/13.0638081a.iframe.bundle.js +0 -2
  154. package/storybook-static/161.a19908ac.iframe.bundle.js +0 -2
  155. package/storybook-static/167.3fa3a909.iframe.bundle.js +0 -1
  156. package/storybook-static/294.ce38f65c.iframe.bundle.js +0 -1
  157. package/storybook-static/314.568bd9af.iframe.bundle.js +0 -2
  158. package/storybook-static/364.0b18ef67.iframe.bundle.js +0 -1
  159. package/storybook-static/735.1625d9f4.iframe.bundle.js +0 -2
  160. package/storybook-static/742.597501f6.iframe.bundle.js +0 -1
  161. package/storybook-static/844.aec20bdb.iframe.bundle.js.map +0 -1
  162. package/storybook-static/936.fd850a3f.iframe.bundle.js +0 -1
  163. package/storybook-static/961.0e5457c5.iframe.bundle.js +0 -2
  164. package/storybook-static/main.069281cf.iframe.bundle.js +0 -1
  165. package/storybook-static/stories-Badge-stories.484f7206.iframe.bundle.js +0 -1
  166. package/storybook-static/stories-Button-stories.5e29be85.iframe.bundle.js +0 -1
  167. package/storybook-static/stories-ButtonGroup-stories.cc89968c.iframe.bundle.js +0 -1
  168. package/storybook-static/stories-Colors-stories.f892dc75.iframe.bundle.js +0 -2
  169. package/storybook-static/stories-Configure-mdx.81346d97.iframe.bundle.js +0 -1
  170. package/storybook-static/stories-Header-stories.cf691094.iframe.bundle.js +0 -2
  171. package/storybook-static/stories-MobileNav-stories.f04cccdd.iframe.bundle.js +0 -1
  172. package/storybook-static/stories-Page-stories.0c9aa29d.iframe.bundle.js +0 -2
  173. package/storybook-static/stories-Paginate-stories.3b161781.iframe.bundle.js +0 -1
  174. package/storybook-static/stories-Select-stories.7556ae0d.iframe.bundle.js +0 -1
  175. package/storybook-static/stories-SideNav-stories.093fac6a.iframe.bundle.js +0 -1
  176. package/storybook-static/stories-TextInput-stories.6d3e15c6.iframe.bundle.js +0 -1
  177. package/storybook-static/stories-Typography-stories.6640f7ac.iframe.bundle.js +0 -2
  178. /package/storybook-static/{125.65b26339.iframe.bundle.js.LICENSE.txt โ†’ 125.df7cc93e.iframe.bundle.js.LICENSE.txt} +0 -0
  179. /package/storybook-static/{13.0638081a.iframe.bundle.js.LICENSE.txt โ†’ 13.d4c3993e.iframe.bundle.js.LICENSE.txt} +0 -0
  180. /package/storybook-static/{161.a19908ac.iframe.bundle.js.LICENSE.txt โ†’ 161.f5193502.iframe.bundle.js.LICENSE.txt} +0 -0
  181. /package/storybook-static/{314.568bd9af.iframe.bundle.js.LICENSE.txt โ†’ 314.c9f9245e.iframe.bundle.js.LICENSE.txt} +0 -0
  182. /package/storybook-static/{735.1625d9f4.iframe.bundle.js.LICENSE.txt โ†’ 735.c396ee77.iframe.bundle.js.LICENSE.txt} +0 -0
  183. /package/storybook-static/{844.aec20bdb.iframe.bundle.js.LICENSE.txt โ†’ 844.3bb89aad.iframe.bundle.js.LICENSE.txt} +0 -0
  184. /package/storybook-static/{961.0e5457c5.iframe.bundle.js.LICENSE.txt โ†’ 961.c3df469f.iframe.bundle.js.LICENSE.txt} +0 -0
  185. /package/storybook-static/{stories-Colors-stories.f892dc75.iframe.bundle.js.LICENSE.txt โ†’ stories-Colors-stories.424256b4.iframe.bundle.js.LICENSE.txt} +0 -0
  186. /package/storybook-static/{stories-Header-stories.cf691094.iframe.bundle.js.LICENSE.txt โ†’ stories-Header-stories.df09e844.iframe.bundle.js.LICENSE.txt} +0 -0
  187. /package/storybook-static/{stories-Page-stories.0c9aa29d.iframe.bundle.js.LICENSE.txt โ†’ stories-Page-stories.ab66c885.iframe.bundle.js.LICENSE.txt} +0 -0
  188. /package/storybook-static/{stories-Typography-stories.6640f7ac.iframe.bundle.js.LICENSE.txt โ†’ stories-Typography-stories.a31da7ce.iframe.bundle.js.LICENSE.txt} +0 -0
@@ -184,184 +184,4 @@ body {
184
184
  code {
185
185
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
186
186
  monospace;
187
- }
188
-
189
-
190
- .App {
191
- text-align: center;
192
- }
193
-
194
- .App-logo {
195
- height: 40vmin;
196
- pointer-events: none;
197
- }
198
-
199
- @media (prefers-reduced-motion: no-preference) {
200
- .App-logo {
201
- animation: App-logo-spin infinite 20s linear;
202
- }
203
- }
204
-
205
- .App-header {
206
- background-color: #282c34;
207
- min-height: 100vh;
208
- display: flex;
209
- flex-direction: column;
210
- align-items: center;
211
- justify-content: center;
212
- font-size: calc(10px + 2vmin);
213
- color: white;
214
- }
215
-
216
- .App-link {
217
- color: #61dafb;
218
- }
219
-
220
- @keyframes App-logo-spin {
221
- from {
222
- transform: rotate(0deg);
223
- }
224
- to {
225
- transform: rotate(360deg);
226
- }
227
- }
228
-
229
-
230
-
231
- .storybook-button {
232
- display: inline-block;
233
- cursor: pointer;
234
- border: 0;
235
- border-radius: 3em;
236
- font-weight: 700;
237
- line-height: 1;
238
- font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
239
- }
240
- .storybook-button--primary {
241
- background-color: #555ab9;
242
- color: white;
243
- }
244
- .storybook-button--secondary {
245
- box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
246
- background-color: transparent;
247
- color: #333;
248
- }
249
- .storybook-button--small {
250
- padding: 10px 16px;
251
- font-size: 12px;
252
- }
253
- .storybook-button--medium {
254
- padding: 11px 20px;
255
- font-size: 14px;
256
- }
257
- .storybook-button--large {
258
- padding: 12px 24px;
259
- font-size: 16px;
260
- }
261
-
262
-
263
- .storybook-header {
264
- display: flex;
265
- justify-content: space-between;
266
- align-items: center;
267
- border-bottom: 1px solid rgba(0, 0, 0, 0.1);
268
- padding: 15px 20px;
269
- font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
270
- }
271
-
272
- .storybook-header svg {
273
- display: inline-block;
274
- vertical-align: top;
275
- }
276
-
277
- .storybook-header h1 {
278
- display: inline-block;
279
- vertical-align: top;
280
- margin: 6px 0 6px 10px;
281
- font-weight: 700;
282
- font-size: 20px;
283
- line-height: 1;
284
- }
285
-
286
- .storybook-header button + button {
287
- margin-left: 10px;
288
- }
289
-
290
- .storybook-header .welcome {
291
- margin-right: 10px;
292
- color: #333;
293
- font-size: 14px;
294
- }
295
-
296
-
297
- .storybook-page {
298
- margin: 0 auto;
299
- padding: 48px 20px;
300
- max-width: 600px;
301
- color: #333;
302
- font-size: 14px;
303
- line-height: 24px;
304
- font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
305
- }
306
-
307
- .storybook-page h2 {
308
- display: inline-block;
309
- vertical-align: top;
310
- margin: 0 0 4px;
311
- font-weight: 700;
312
- font-size: 32px;
313
- line-height: 1;
314
- }
315
-
316
- .storybook-page p {
317
- margin: 1em 0;
318
- }
319
-
320
- .storybook-page a {
321
- color: inherit;
322
- }
323
-
324
- .storybook-page ul {
325
- margin: 1em 0;
326
- padding-left: 30px;
327
- }
328
-
329
- .storybook-page li {
330
- margin-bottom: 8px;
331
- }
332
-
333
- .storybook-page .tip {
334
- display: inline-block;
335
- vertical-align: top;
336
- margin-right: 10px;
337
- border-radius: 1em;
338
- background: #e7fdd8;
339
- padding: 4px 12px;
340
- color: #357a14;
341
- font-weight: 700;
342
- font-size: 11px;
343
- line-height: 12px;
344
- }
345
-
346
- .storybook-page .tip-wrapper {
347
- margin-top: 40px;
348
- margin-bottom: 40px;
349
- font-size: 13px;
350
- line-height: 20px;
351
- }
352
-
353
- .storybook-page .tip-wrapper svg {
354
- display: inline-block;
355
- vertical-align: top;
356
- margin-top: 3px;
357
- margin-right: 4px;
358
- width: 12px;
359
- height: 12px;
360
- }
361
-
362
- .storybook-page .tip-wrapper svg path {
363
- fill: #1ea7fd;
364
- }
365
-
366
-
367
-
187
+ }
@@ -0,0 +1,48 @@
1
+
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import * as stories from '../stories/Badge.stories';
6
+
7
+ const {
8
+ Default, LeadingIconBadge, ImageIconBadge, TrailingIconBadge
9
+ } = composeStories(stories);
10
+
11
+
12
+ describe('๐Ÿ“˜ Badge Storybook Stories', () => {
13
+ test('renders Default badge', () => {
14
+ const Story = Default;
15
+ const { container } = render(
16
+ Story(Story.args ?? {})
17
+ );
18
+ expect(screen.getByText('Label')).toBeInTheDocument();
19
+ expect(container).toMatchSnapshot(); // Optional: snapshot for structure
20
+ });
21
+
22
+ test('renders Badge with leading icon', () => {
23
+ const Story = LeadingIconBadge;
24
+ render(
25
+ Story(Story.args ?? {})
26
+ );
27
+ expect(screen.getByText('Label')).toBeInTheDocument();
28
+ expect(screen.getByTestId('leadingIcon')).toBeInTheDocument(); // Checks for <FiStar /> icon
29
+ });
30
+
31
+ test('renders Badge with image icon', () => {
32
+ const Story = ImageIconBadge;
33
+ render(
34
+ Story(Story.args ?? {})
35
+ );
36
+ expect(screen.getByText('Newzeland')).toBeInTheDocument();
37
+ expect(screen.getByTestId('iconOnly')).toBeInTheDocument(); // Checks for image icon
38
+ });
39
+
40
+ test('renders Badge with trailing icon', () => {
41
+ const Story = TrailingIconBadge;
42
+ render(
43
+ Story(Story.args ?? {})
44
+ );
45
+ expect(screen.getByText('Label')).toBeInTheDocument();
46
+ expect(screen.getByTestId('trailingIcon')).toBeInTheDocument(); // Checks for <FiArrowRight /> icon
47
+ });
48
+ });
@@ -0,0 +1,69 @@
1
+
2
+ import React from 'react';
3
+ import '@testing-library/jest-dom';
4
+ import { render, screen } from '@testing-library/react';
5
+ import { composeStories } from '@storybook/react';
6
+ import * as stories from '../stories/Button.stories';
7
+
8
+ const {
9
+ Default, Variants, Sizes, LeadingIconButton, TrailingIconButton, IconOnlyButton
10
+ } = composeStories(stories);
11
+
12
+ describe('๐Ÿ“˜ Button Storybook Stories', () => {
13
+ test('renders Default button', () => {
14
+ const Story = Default;
15
+ const { container } = render(
16
+ Story(Story.args ?? {})
17
+ );
18
+ expect(screen.getByText('Primary')).toBeInTheDocument();
19
+ expect(container).toMatchSnapshot();
20
+ });
21
+
22
+ test('renders all button variants', () => {
23
+ const Story = Variants;
24
+ const { container } = render(
25
+ Story(Story.args ?? {})
26
+ );
27
+ ['Primary', 'Secondary', 'Secondary Gray', 'Tertiary', 'Tertiary Gray'].forEach(label => {
28
+ expect(screen.getByText(label)).toBeInTheDocument();
29
+ });
30
+ expect(container).toMatchSnapshot();
31
+ });
32
+
33
+ test('renders all button sizes', () => {
34
+ const Story = Sizes;
35
+ const { container } = render(
36
+ Story(Story.args ?? {})
37
+ );
38
+ ['sm', 'md', 'lg', 'xl', '2xl'].forEach(label => {
39
+ expect(screen.getByText(label)).toBeInTheDocument();
40
+ });
41
+ expect(container).toMatchSnapshot();
42
+ });
43
+
44
+ test('renders button with trailing icon', () => {
45
+ const Story = TrailingIconButton;
46
+ const { container } = render(
47
+ Story(Story.args ?? {})
48
+ );
49
+ expect(screen.getByText('Button')).toBeInTheDocument();
50
+ expect(container.querySelector('svg')).toBeInTheDocument(); // FiArrowRight
51
+ });
52
+
53
+ test('renders button with leading icon', () => {
54
+ const Story = LeadingIconButton;
55
+ const { container } = render(
56
+ Story(Story.args ?? {})
57
+ );
58
+ expect(screen.getByText('Button')).toBeInTheDocument();
59
+ expect(container.querySelector('svg')).toBeInTheDocument(); // FiArrowLeft
60
+ });
61
+
62
+ test('renders icon-only button', () => {
63
+ const Story = IconOnlyButton;
64
+ const { container } = render(
65
+ Story(Story.args ?? {})
66
+ );
67
+ expect(container.querySelector('svg')).toBeInTheDocument(); // FiStar
68
+ });
69
+ });
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import * as stories from '../stories/ButtonGroup.stories';
6
+ import { options1, options2 } from "../data/options";
7
+
8
+ const {
9
+ LabelButtonGroup,
10
+ IconButtonGroup,
11
+ LabelIconButtonGroup
12
+ } = composeStories(stories);
13
+
14
+ describe('๐Ÿ“˜ ButtonGroup Storybook Stories', () => {
15
+
16
+ test('renders LabelButtonGroup', () => {
17
+ const Story = LabelButtonGroup;
18
+ const { container } = render(Story(Story.args ?? {}));
19
+
20
+ const labelTexts = ['Leading', 'Middle', 'Trailing'];
21
+
22
+ labelTexts.forEach((val) => {
23
+ expect(screen.getByText(val)).toBeInTheDocument();
24
+ });
25
+
26
+ expect(container).toMatchSnapshot();
27
+ });
28
+
29
+ test('renders IconButtonGroup with icons', () => {
30
+ const Story = IconButtonGroup;
31
+ const { container } = render(Story(Story.args ?? {}));
32
+
33
+ expect(container.querySelector('svg')).toBeInTheDocument(); // Check for an icon (List or Grid)
34
+ expect(container).toMatchSnapshot();
35
+ });
36
+
37
+ test('renders LabelIconButtonGroup', () => {
38
+ const Story = LabelIconButtonGroup;
39
+ const { container } = render(Story(Story.args ?? {}));
40
+
41
+ const labelTexts = ['First', 'Second', 'Third'];
42
+
43
+ labelTexts.forEach((text) => {
44
+ expect(screen.getByText(text)).toBeInTheDocument();
45
+ });
46
+ expect(container.querySelector('svg')).toBeInTheDocument(); // Check for icons
47
+
48
+ expect(container).toMatchSnapshot();
49
+ });
50
+
51
+ });
@@ -0,0 +1,66 @@
1
+ import React from "react";
2
+ import "@testing-library/jest-dom";
3
+ import { composeStories } from '@storybook/react';
4
+ import * as stories from "../stories/MobileNav.stories";
5
+ import { render, fireEvent, screen, waitFor } from "@testing-library/react";
6
+
7
+ const { Default } = composeStories(stories);
8
+
9
+ describe("MobileNavbar and SideNav interaction", () => {
10
+
11
+ test("should render the mobile nav toggle button", () => {
12
+ const Story = Default;
13
+ render(Story(Story.args ?? {}));
14
+ const toggleBtn = screen.getByTestId("mobile-nav-toggle");
15
+ expect(toggleBtn).toBeInTheDocument();
16
+ });
17
+
18
+ test("should open SideNav on toggle button click", async () => {
19
+ const Story = Default;
20
+ render(Story(Story.args ?? {}));
21
+ fireEvent.click(screen.getByTestId("mobile-nav-toggle"));
22
+
23
+ const sideNav = await screen.findByTestId("side-nav");
24
+ expect(sideNav).toBeInTheDocument();
25
+ });
26
+
27
+ test("should close SideNav on close icon click", async () => {
28
+ const Story = Default;
29
+ render(Story(Story.args ?? {}));
30
+
31
+ fireEvent.click(screen.getByTestId("mobile-nav-toggle"));
32
+ const sideNav = await screen.findByTestId("side-nav");
33
+ expect(sideNav).toBeInTheDocument();
34
+
35
+ const closeIcon = await screen.findByTestId("close-icon");
36
+ fireEvent.click(closeIcon);
37
+
38
+ await waitFor(() => {
39
+ expect(screen.queryByTestId("side-nav")).not.toBeInTheDocument();
40
+ });
41
+ });
42
+
43
+ test("should close SideNav on backdrop click", async () => {
44
+ const Story = Default;
45
+ render(Story(Story.args ?? {}));
46
+
47
+ fireEvent.click(screen.getByTestId("mobile-nav-toggle"));
48
+ expect(await screen.findByTestId("side-nav")).toBeInTheDocument();
49
+
50
+ fireEvent.click(screen.getByTestId("backdrop"));
51
+
52
+ await waitFor(() => {
53
+ expect(screen.queryByTestId("side-nav")).not.toBeInTheDocument();
54
+ });
55
+ });
56
+
57
+ test("should show username and email when SideNav is open", async () => {
58
+ const Story = Default;
59
+ render(Story(Story.args ?? {}));
60
+
61
+ fireEvent.click(screen.getByTestId("mobile-nav-toggle"));
62
+
63
+ expect(await screen.findByText("Veronica Woods")).toBeInTheDocument();
64
+ expect(await screen.findByText("veronica@example.com")).toBeInTheDocument();
65
+ });
66
+ });
@@ -0,0 +1,86 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import * as stories from '../stories/Paginate.stories';
6
+
7
+ const {
8
+ DesktopPagination,
9
+ MobilePagination
10
+ } = composeStories(stories);
11
+
12
+ describe('๐Ÿ“˜ Pagination Storybook Stories', () => {
13
+ test('renders DesktopPagination component', () => {
14
+ const Story = DesktopPagination;
15
+ const { container } = render(
16
+ Story(Story.args ?? {})
17
+ );
18
+
19
+ expect(screen.getByText('1')).toBeInTheDocument();
20
+ expect(screen.getByText('Previous')).toBeInTheDocument();
21
+ expect(screen.getByText('Next')).toBeInTheDocument();
22
+
23
+ expect(container).toMatchSnapshot();
24
+ });
25
+
26
+ test('renders MobilePagination component', () => {
27
+ const Story = MobilePagination;
28
+ const { container } = render(
29
+ Story(Story.args ?? {})
30
+ );
31
+
32
+ expect(container.querySelector('svg')).toBeInTheDocument(); // FiArrowRight
33
+
34
+ expect(screen.getByTestId('prevBtn')).toBeInTheDocument();
35
+ expect(screen.getByTestId('nextBtn')).toBeInTheDocument();
36
+ expect(screen.getByText('Page 0 of 10')).toBeInTheDocument();
37
+
38
+ expect(container).toMatchSnapshot();
39
+ });
40
+
41
+ test('renders DesktopPagination with total pages', () => {
42
+ const Story = DesktopPagination;
43
+ const { container } = render(
44
+ Story({ totalPages: 5 })
45
+ );
46
+
47
+ for (let i = 1; i <= 5; i++) {
48
+ expect(screen.getByText(i.toString())).toBeInTheDocument();
49
+ }
50
+
51
+ expect(container).toMatchSnapshot();
52
+ });
53
+
54
+ test('renders MobilePagination with page information', () => {
55
+ const Story = MobilePagination;
56
+ const { container } = render(
57
+ Story({ totalPages: 5 })
58
+ );
59
+
60
+ expect(screen.getByText('Page 0 of 5')).toBeInTheDocument();
61
+
62
+ expect(container).toMatchSnapshot();
63
+ });
64
+
65
+ test('renders DesktopPagination in dark mode', () => {
66
+ const Story = DesktopPagination;
67
+ const { container } = render(
68
+ Story({ darkMode: true, totalPages: 5 })
69
+ );
70
+
71
+ expect(container.firstChild).toHaveClass('dark'); // Assuming you have dark mode styling applied with a class 'dark'
72
+
73
+ expect(container).toMatchSnapshot();
74
+ });
75
+
76
+ test('renders MobilePagination in dark mode', () => {
77
+ const Story = MobilePagination;
78
+ const { container } = render(
79
+ Story({ darkMode: true, totalPages: 5 })
80
+ );
81
+
82
+ expect(container.firstChild).toHaveClass('dark');
83
+
84
+ expect(container).toMatchSnapshot();
85
+ });
86
+ });
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import * as stories from '../stories/Select.stories';
6
+ import { prices, countries } from '../data';
7
+
8
+ const { Default, SelectWithIcon } = composeStories(stories);
9
+
10
+ describe('๐Ÿงช Select Story Tests (Direct function call style)', () => {
11
+
12
+ test('Default story renders with a default country and placeholder', () => {
13
+ const Story = Default;
14
+ const { container } = render(Story(Story.args ?? {}));
15
+
16
+ // Check if the default country is visible
17
+ expect(screen.getByText('Ahmedabad, IN')).toBeInTheDocument();
18
+ // Snapshot test
19
+ expect(container).toMatchSnapshot();
20
+ });
21
+
22
+ // Test case 2: SelectWithIcon story renders with a leading dollar sign icon and price
23
+ test('SelectWithIcon story renders with a leading dollar sign icon and price', () => {
24
+ const Story = SelectWithIcon;
25
+ const { container } = render(Story(Story.args ?? {}));
26
+
27
+ // Check if the icon is visible (using a test ID or a class, depending on how the icon is rendered)
28
+ expect(screen.getByTestId('leading-icon')).toBeInTheDocument(); // If you've added a data-testid to the icon
29
+ // Check if the default price is visible
30
+ expect(screen.getByText('Any price')).toBeInTheDocument();
31
+ // Snapshot test
32
+ expect(container).toMatchSnapshot();
33
+ });
34
+
35
+ // Test case 3: Typing works in Default Select (Country selection)
36
+ test('typing works in Default Select (Country selection)', async () => {
37
+ const Story = Default;
38
+ render(Story(Story.args ?? {}));
39
+
40
+ const selectButton = screen.getByRole('button', { name: /Ahmedabad, IN/i });
41
+ expect(selectButton).toBeInTheDocument();
42
+ fireEvent.click(selectButton);
43
+
44
+ const option = await screen.findByText('Amsterdam, NL');
45
+
46
+ expect(option).toHaveTextContent('Amsterdam, NL');
47
+ });
48
+
49
+ test('typing works in SelectWithIcon (Price selection)', async() => {
50
+ const Story = SelectWithIcon;
51
+ render(Story(Story.args ?? {}));
52
+
53
+ const priceSelect = screen.getByRole('button', { name: /any price/i });
54
+ expect(priceSelect).toBeInTheDocument();
55
+ fireEvent.click(priceSelect);
56
+
57
+ const option = await screen.findByText('100 - 200');
58
+ fireEvent.click(option);
59
+
60
+ expect(priceSelect).toHaveTextContent('100 - 200');
61
+ });
62
+ });
63
+
@@ -0,0 +1,43 @@
1
+ import React from "react";
2
+ import "@testing-library/jest-dom";
3
+ import { composeStories } from '@storybook/react';
4
+ import * as stories from "../stories/SideNav.stories";
5
+ import { render, fireEvent, screen, waitFor } from "@testing-library/react";
6
+
7
+ const { Default } = composeStories(stories);
8
+
9
+ describe("SideNav Component", () => {
10
+ test("should render SideNav when open is true", () => {
11
+ const Story = Default;
12
+ render(Story(Story.args ?? {}));
13
+
14
+ const sideNav = screen.getByTestId("side-nav");
15
+ expect(sideNav).toBeInTheDocument();
16
+ });
17
+
18
+ test("should display username and email in SideNav", () => {
19
+ const Story = Default;
20
+ render(Story(Story.args ?? {}));
21
+
22
+ expect(screen.getByText("Veronica Woods")).toBeInTheDocument();
23
+ expect(screen.getByText("veronica@example.com")).toBeInTheDocument();
24
+ });
25
+
26
+ test("should render top and bottom nav items", () => {
27
+ const Story = Default;
28
+ render(Story(Story.args ?? {}));
29
+
30
+ expect(screen.getByText("Home")).toBeInTheDocument();
31
+ expect(screen.getByText("Settings")).toBeInTheDocument();
32
+ });
33
+
34
+ test("should respond correctly when a nav item is clicked", () => {
35
+ const Story = Default;
36
+ render(Story(Story.args ?? {}));
37
+
38
+ const navItem = screen.getByText("Home");
39
+ fireEvent.click(navItem);
40
+
41
+ expect(navItem).toBeInTheDocument();
42
+ });
43
+ });
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen, fireEvent } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import * as stories from '../stories/TextInput.stories';
6
+
7
+ const {Default, LeadingTextInput} = composeStories(stories);
8
+
9
+ describe('๐Ÿงช TextInput Story Tests (Direct function call style)', () => {
10
+ test('Default story renders with email input and error', () => {
11
+ const Story = Default;
12
+ const { container } = render(
13
+ Story(Story.args ?? {})
14
+ );
15
+
16
+ expect(screen.getAllByLabelText(/Email/i)[0]).toBeInTheDocument();
17
+ expect(screen.getByText(/This is an error message/i)).toBeInTheDocument();
18
+ expect(container).toMatchSnapshot();
19
+ });
20
+
21
+ test('LeadingTextInput story renders with https prefix and error', () => {
22
+ const Story = LeadingTextInput;
23
+ const { container } = render(
24
+ Story(Story.args ?? {})
25
+ );
26
+
27
+ expect(screen.getAllByLabelText(/Website/i)[0]).toBeInTheDocument();
28
+ expect(screen.getAllByText('https://')[0]).toBeInTheDocument();
29
+ expect(screen.getByText(/This is an error message/i)).toBeInTheDocument();
30
+ expect(container).toMatchSnapshot();
31
+ });
32
+
33
+ test('typing works in Default TextInput', () => {
34
+ const Story = Default;
35
+ render(Story(Story.args ?? {}));
36
+
37
+ const input = screen.getAllByLabelText(/Email/i)[0] as HTMLInputElement;
38
+
39
+ fireEvent.change(input, { target: { value: 'femina@example.com' } });
40
+ expect(input.value).toBe('femina@example.com');
41
+ });
42
+ });
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { composeStories } from '@storybook/react';
5
+ import * as stories from '../stories/Typography.stories';
6
+
7
+ const {
8
+ TypographyDynamic,
9
+ TypographyHeadings,
10
+ TypographyText,
11
+ } = composeStories(stories);
12
+
13
+ describe('๐Ÿ“ Typography Stories', () => {
14
+ test('should render heading variant text', () => {
15
+ const Story = TypographyDynamic;
16
+ const { container } = render(
17
+ // Manually call the story function (with args and dummy context)
18
+ Story(Story.args ?? {})
19
+ );
20
+ expect(screen.getByText(/Display h1/i)).toBeInTheDocument();
21
+ expect(screen.getByText(/regular/i)).toBeInTheDocument();
22
+ });
23
+
24
+ test('TypographyHeadings renders all heading variants', () => {
25
+ const Story = TypographyHeadings;
26
+ render(Story(Story.args ?? {}));
27
+
28
+ ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach((heading) => {
29
+ expect(screen.getByText(`Display ${heading}`)).toBeInTheDocument();
30
+ });
31
+ });
32
+
33
+ test('TypographyText renders all text variants', () => {
34
+ const Story = TypographyText;
35
+ render(Story(Story.args ?? {}));
36
+
37
+ ['xl', 'lg', 'md', 'sm', 'xs'].forEach((variant) => {
38
+ expect(screen.getByText(`Text ${variant}`)).toBeInTheDocument();
39
+ });
40
+ });
41
+ });