@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.
- package/.storybook/main.ts +40 -2
- package/dist/@interfaces/Badge.d.d.ts.map +1 -1
- package/dist/@interfaces/Button.d.d.ts.map +1 -1
- package/dist/@interfaces/Color.d.d.ts.map +1 -1
- package/dist/@interfaces/IButtonItem.d.d.ts.map +1 -1
- package/dist/@interfaces/ISubNavItem.d.d.ts.map +1 -1
- package/dist/@interfaces/MobileNavProps.d.d.ts.map +1 -1
- package/dist/@interfaces/NavItem.d.d.ts.map +1 -1
- package/dist/@interfaces/Pagination.d.d.ts.map +1 -1
- package/dist/@interfaces/Select.d.d.ts.map +1 -1
- package/dist/@interfaces/SideNavProps.d.d.ts.map +1 -1
- package/dist/@interfaces/TextInput.d.d.ts.map +1 -1
- package/dist/@interfaces/index.d.ts.map +1 -1
- package/dist/Badge.d.ts.map +1 -1
- package/dist/Button.d.ts.map +1 -1
- package/dist/ButtonGroup.d.ts.map +1 -1
- package/dist/ColorBox.d.ts.map +1 -1
- package/dist/Header.d.ts.map +1 -1
- package/dist/Nav/MobileNav.d.ts.map +1 -1
- package/dist/Nav/NavItem.d.ts.map +1 -1
- package/dist/Nav/SideNav.d.ts.map +1 -1
- package/dist/Nav/SubNavItem.d.ts.map +1 -1
- package/dist/Paginate.d.ts.map +1 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/StoryLayout.d.ts.map +1 -1
- package/dist/TextInput.d.ts.map +1 -1
- package/dist/Typography.d.ts.map +1 -1
- package/dist/box-ui.cjs.development.js +17 -11
- package/dist/box-ui.cjs.development.js.map +1 -1
- package/dist/box-ui.cjs.production.min.js +1 -1
- package/dist/box-ui.cjs.production.min.js.map +1 -1
- package/dist/box-ui.esm.js +17 -11
- package/dist/box-ui.esm.js.map +1 -1
- package/dist/data/colors.d.ts.map +1 -1
- package/dist/data/countries.d.ts.map +1 -1
- package/dist/data/images/index.d.ts.map +1 -1
- package/dist/data/index.d.ts.map +1 -1
- package/dist/data/navItems.d.ts.map +1 -1
- package/dist/data/options.d.ts.map +1 -1
- package/dist/data/prices.d.ts.map +1 -1
- package/dist/hooks/useIconClassName.d.ts.map +1 -1
- package/dist/hooks/useIconProps.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/jest.config.d.ts +9 -0
- package/dist/jest.config.d.ts.map +1 -0
- package/dist/reportWebVitals.d.ts.map +1 -1
- package/dist/setupTests.d.ts.map +1 -1
- package/dist/stories/Badge.stories.d.ts +3 -4
- package/dist/stories/Badge.stories.d.ts.map +1 -1
- package/dist/stories/Button.stories.d.ts +3 -4
- package/dist/stories/Button.stories.d.ts.map +1 -1
- package/dist/stories/ButtonGroup.stories.d.ts +4 -4
- package/dist/stories/ButtonGroup.stories.d.ts.map +1 -1
- package/dist/stories/Colors.stories.d.ts +3 -3
- package/dist/stories/Colors.stories.d.ts.map +1 -1
- package/dist/stories/MobileNav.stories.d.ts +3 -4
- package/dist/stories/MobileNav.stories.d.ts.map +1 -1
- package/dist/stories/Paginate.stories.d.ts +3 -4
- package/dist/stories/Paginate.stories.d.ts.map +1 -1
- package/dist/stories/Select.stories.d.ts +3 -4
- package/dist/stories/Select.stories.d.ts.map +1 -1
- package/dist/stories/SideNav.stories.d.ts +3 -4
- package/dist/stories/SideNav.stories.d.ts.map +1 -1
- package/dist/stories/TextInput.stories.d.ts +3 -4
- package/dist/stories/TextInput.stories.d.ts.map +1 -1
- package/dist/stories/Typography.stories.d.ts +4 -4
- package/dist/stories/Typography.stories.d.ts.map +1 -1
- package/dist/utils/IconWrapper.d.ts +8 -0
- package/dist/utils/IconWrapper.d.ts.map +1 -0
- package/jest.config.js +13 -0
- package/jest.setup.ts +3 -0
- package/netlify.toml +3 -0
- package/package.json +24 -26
- package/src/Nav/MobileNav.tsx +2 -0
- package/src/Nav/SideNav.tsx +1 -0
- package/src/Paginate.tsx +2 -0
- package/src/Select.tsx +1 -1
- package/src/TextInput.tsx +23 -27
- package/src/index.js +1 -1
- package/src/stories/Badge.stories.tsx +6 -8
- package/src/stories/Button.stories.tsx +21 -8
- package/src/stories/ButtonGroup.stories.tsx +48 -48
- package/src/stories/Colors.stories.tsx +2 -4
- package/src/stories/MobileNav.stories.tsx +29 -19
- package/src/stories/Paginate.stories.tsx +36 -35
- package/src/stories/Select.stories.tsx +46 -43
- package/src/stories/SideNav.stories.tsx +18 -19
- package/src/stories/TextInput.stories.tsx +81 -71
- package/src/stories/Typography.stories.tsx +2 -4
- package/src/styles/global.css +1 -181
- package/src/tests/Badge.test.tsx +48 -0
- package/src/tests/Button.test.tsx +69 -0
- package/src/tests/ButtonGroup.test.tsx +51 -0
- package/src/tests/MobileNav.test.tsx +66 -0
- package/src/tests/Paginate.test.tsx +86 -0
- package/src/tests/Select.test.tsx +63 -0
- package/src/tests/SideNav.test.tsx +43 -0
- package/src/tests/TextInput.test.tsx +42 -0
- package/src/tests/Typography.test.tsx +41 -0
- package/src/tests/__snapshots__/Badge.test.tsx.snap +13 -0
- package/src/tests/__snapshots__/Button.test.tsx.snap +106 -0
- package/src/tests/__snapshots__/ButtonGroup.test.tsx.snap +228 -0
- package/src/tests/__snapshots__/Paginate.test.tsx.snap +580 -0
- package/src/tests/__snapshots__/Select.test.tsx.snap +119 -0
- package/src/tests/__snapshots__/TextInput.test.tsx.snap +323 -0
- package/src/utils/IconWrapper.tsx +11 -0
- package/storybook-static/{125.65b26339.iframe.bundle.js โ 125.df7cc93e.iframe.bundle.js} +3 -3
- package/storybook-static/125.df7cc93e.iframe.bundle.js.map +1 -0
- package/storybook-static/13.d4c3993e.iframe.bundle.js +2 -0
- package/storybook-static/161.f5193502.iframe.bundle.js +2 -0
- package/storybook-static/167.89fa6ac2.iframe.bundle.js +1 -0
- package/storybook-static/294.eccdc80d.iframe.bundle.js +1 -0
- package/storybook-static/314.c9f9245e.iframe.bundle.js +2 -0
- package/storybook-static/364.1cfcaebe.iframe.bundle.js +1 -0
- package/storybook-static/735.c396ee77.iframe.bundle.js +2 -0
- package/storybook-static/742.52c662a4.iframe.bundle.js +1 -0
- package/storybook-static/{844.aec20bdb.iframe.bundle.js โ 844.3bb89aad.iframe.bundle.js} +3 -3
- package/storybook-static/844.3bb89aad.iframe.bundle.js.map +1 -0
- package/storybook-static/936.c827da74.iframe.bundle.js +1 -0
- package/storybook-static/961.c3df469f.iframe.bundle.js +2 -0
- package/storybook-static/iframe.html +3 -3
- package/storybook-static/main.179173d1.iframe.bundle.js +1 -0
- package/storybook-static/project.json +1 -1
- package/storybook-static/{runtime~main.295ddda4.iframe.bundle.js โ runtime~main.70344601.iframe.bundle.js} +1 -1
- package/storybook-static/static/css/main.08036cd2.css.map +1 -1
- package/storybook-static/stories-Badge-stories.a924d6d5.iframe.bundle.js +1 -0
- package/storybook-static/stories-Button-stories.a3c88a14.iframe.bundle.js +1 -0
- package/storybook-static/stories-ButtonGroup-stories.2c74e4c4.iframe.bundle.js +1 -0
- package/storybook-static/stories-Colors-stories.424256b4.iframe.bundle.js +2 -0
- package/storybook-static/stories-Configure-mdx.46ebbf59.iframe.bundle.js +1 -0
- package/storybook-static/stories-Header-stories.df09e844.iframe.bundle.js +2 -0
- package/storybook-static/stories-MobileNav-stories.eb9a0ca6.iframe.bundle.js +1 -0
- package/storybook-static/stories-Page-stories.ab66c885.iframe.bundle.js +2 -0
- package/storybook-static/stories-Paginate-stories.086f736a.iframe.bundle.js +1 -0
- package/storybook-static/stories-Select-stories.4c04edb3.iframe.bundle.js +1 -0
- package/storybook-static/stories-SideNav-stories.272a4362.iframe.bundle.js +1 -0
- package/storybook-static/stories-TextInput-stories.cfa81131.iframe.bundle.js +1 -0
- package/storybook-static/stories-Typography-stories.a31da7ce.iframe.bundle.js +2 -0
- package/tailwind.config.js +1 -1
- package/tsconfig.json +6 -3
- package/tsdx.config.js +14 -0
- package/dist/Page.d.ts +0 -3
- package/dist/Page.d.ts.map +0 -1
- package/dist/stories/Header.stories.d.ts +0 -20
- package/dist/stories/Header.stories.d.ts.map +0 -1
- package/dist/stories/Page.stories.d.ts +0 -14
- package/dist/stories/Page.stories.d.ts.map +0 -1
- package/src/Page.tsx +0 -72
- package/src/stories/Configure.mdx +0 -364
- package/src/stories/Header.stories.ts +0 -33
- package/src/stories/Page.stories.ts +0 -32
- package/storybook-static/125.65b26339.iframe.bundle.js.map +0 -1
- package/storybook-static/13.0638081a.iframe.bundle.js +0 -2
- package/storybook-static/161.a19908ac.iframe.bundle.js +0 -2
- package/storybook-static/167.3fa3a909.iframe.bundle.js +0 -1
- package/storybook-static/294.ce38f65c.iframe.bundle.js +0 -1
- package/storybook-static/314.568bd9af.iframe.bundle.js +0 -2
- package/storybook-static/364.0b18ef67.iframe.bundle.js +0 -1
- package/storybook-static/735.1625d9f4.iframe.bundle.js +0 -2
- package/storybook-static/742.597501f6.iframe.bundle.js +0 -1
- package/storybook-static/844.aec20bdb.iframe.bundle.js.map +0 -1
- package/storybook-static/936.fd850a3f.iframe.bundle.js +0 -1
- package/storybook-static/961.0e5457c5.iframe.bundle.js +0 -2
- package/storybook-static/main.069281cf.iframe.bundle.js +0 -1
- package/storybook-static/stories-Badge-stories.484f7206.iframe.bundle.js +0 -1
- package/storybook-static/stories-Button-stories.5e29be85.iframe.bundle.js +0 -1
- package/storybook-static/stories-ButtonGroup-stories.cc89968c.iframe.bundle.js +0 -1
- package/storybook-static/stories-Colors-stories.f892dc75.iframe.bundle.js +0 -2
- package/storybook-static/stories-Configure-mdx.81346d97.iframe.bundle.js +0 -1
- package/storybook-static/stories-Header-stories.cf691094.iframe.bundle.js +0 -2
- package/storybook-static/stories-MobileNav-stories.f04cccdd.iframe.bundle.js +0 -1
- package/storybook-static/stories-Page-stories.0c9aa29d.iframe.bundle.js +0 -2
- package/storybook-static/stories-Paginate-stories.3b161781.iframe.bundle.js +0 -1
- package/storybook-static/stories-Select-stories.7556ae0d.iframe.bundle.js +0 -1
- package/storybook-static/stories-SideNav-stories.093fac6a.iframe.bundle.js +0 -1
- package/storybook-static/stories-TextInput-stories.6d3e15c6.iframe.bundle.js +0 -1
- package/storybook-static/stories-Typography-stories.6640f7ac.iframe.bundle.js +0 -2
- /package/storybook-static/{125.65b26339.iframe.bundle.js.LICENSE.txt โ 125.df7cc93e.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{13.0638081a.iframe.bundle.js.LICENSE.txt โ 13.d4c3993e.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{161.a19908ac.iframe.bundle.js.LICENSE.txt โ 161.f5193502.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{314.568bd9af.iframe.bundle.js.LICENSE.txt โ 314.c9f9245e.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{735.1625d9f4.iframe.bundle.js.LICENSE.txt โ 735.c396ee77.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{844.aec20bdb.iframe.bundle.js.LICENSE.txt โ 844.3bb89aad.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{961.0e5457c5.iframe.bundle.js.LICENSE.txt โ 961.c3df469f.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{stories-Colors-stories.f892dc75.iframe.bundle.js.LICENSE.txt โ stories-Colors-stories.424256b4.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{stories-Header-stories.cf691094.iframe.bundle.js.LICENSE.txt โ stories-Header-stories.df09e844.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{stories-Page-stories.0c9aa29d.iframe.bundle.js.LICENSE.txt โ stories-Page-stories.ab66c885.iframe.bundle.js.LICENSE.txt} +0 -0
- /package/storybook-static/{stories-Typography-stories.6640f7ac.iframe.bundle.js.LICENSE.txt โ stories-Typography-stories.a31da7ce.iframe.bundle.js.LICENSE.txt} +0 -0
package/src/styles/global.css
CHANGED
@@ -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
|
+
});
|