dhre-component-lib 0.0.1 → 0.0.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 (90) hide show
  1. package/coverage/clover.xml +260 -0
  2. package/coverage/coverage-final.json +19 -0
  3. package/coverage/lcov-report/base.css +224 -0
  4. package/coverage/lcov-report/block-navigation.js +87 -0
  5. package/coverage/lcov-report/components/Avatar/Avatar.tsx.html +163 -0
  6. package/coverage/lcov-report/components/Avatar/index.html +116 -0
  7. package/coverage/lcov-report/components/Badge/Badge.tsx.html +160 -0
  8. package/coverage/lcov-report/components/Badge/index.html +116 -0
  9. package/coverage/lcov-report/components/BreadCrumb/BreadCrumb.tsx.html +193 -0
  10. package/coverage/lcov-report/components/BreadCrumb/index.html +116 -0
  11. package/coverage/lcov-report/components/Button/Button.tsx.html +151 -0
  12. package/coverage/lcov-report/components/Button/index.html +116 -0
  13. package/coverage/lcov-report/components/Checkbox/Checkbox.tsx.html +190 -0
  14. package/coverage/lcov-report/components/Checkbox/index.html +116 -0
  15. package/coverage/lcov-report/components/CircularProgress/CircularProgress.tsx.html +196 -0
  16. package/coverage/lcov-report/components/CircularProgress/index.html +116 -0
  17. package/coverage/lcov-report/components/Divider/Divider.tsx.html +157 -0
  18. package/coverage/lcov-report/components/Divider/index.html +116 -0
  19. package/coverage/lcov-report/components/Enum.ts.html +142 -0
  20. package/coverage/lcov-report/components/InputTextField/InputTextField.tsx.html +229 -0
  21. package/coverage/lcov-report/components/InputTextField/index.html +116 -0
  22. package/coverage/lcov-report/components/Link/Link.tsx.html +184 -0
  23. package/coverage/lcov-report/components/Link/index.html +116 -0
  24. package/coverage/lcov-report/components/Modal/Modal.tsx.html +169 -0
  25. package/coverage/lcov-report/components/Modal/index.html +116 -0
  26. package/coverage/lcov-report/components/Notification/Notification.tsx.html +208 -0
  27. package/coverage/lcov-report/components/Notification/index.html +116 -0
  28. package/coverage/lcov-report/components/PdfView/PdfView.tsx.html +400 -0
  29. package/coverage/lcov-report/components/PdfView/index.html +116 -0
  30. package/coverage/lcov-report/components/Progress/Progress.tsx.html +190 -0
  31. package/coverage/lcov-report/components/Progress/index.html +116 -0
  32. package/coverage/lcov-report/components/RadioButton/RadioButton.tsx.html +214 -0
  33. package/coverage/lcov-report/components/RadioButton/index.html +116 -0
  34. package/coverage/lcov-report/components/Switch/Switch.tsx.html +199 -0
  35. package/coverage/lcov-report/components/Switch/index.html +116 -0
  36. package/coverage/lcov-report/components/Tag/Tag.tsx.html +160 -0
  37. package/coverage/lcov-report/components/Tag/index.html +116 -0
  38. package/coverage/lcov-report/components/Tooltip/Tooltip.tsx.html +187 -0
  39. package/coverage/lcov-report/components/Tooltip/index.html +116 -0
  40. package/coverage/lcov-report/components/index.html +116 -0
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/index.html +371 -0
  43. package/coverage/lcov-report/prettify.css +1 -0
  44. package/coverage/lcov-report/prettify.js +2 -0
  45. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. package/coverage/lcov-report/sorter.js +196 -0
  47. package/coverage/lcov.info +457 -0
  48. package/jest.config.ts +1 -1
  49. package/package.json +9 -6
  50. package/src/components/Avatar/Avatar.test.tsx +52 -0
  51. package/src/components/Avatar/__snapshots__/Avatar.test.tsx.snap +9 -0
  52. package/src/components/Badge/Badge.test.tsx +63 -0
  53. package/src/components/Badge/__snapshots__/Badge.test.tsx.snap +9 -0
  54. package/src/components/BreadCrumb/BreadCrumb.test.tsx +90 -0
  55. package/src/components/BreadCrumb/index.ts +1 -0
  56. package/src/components/Button/Button.test.tsx +62 -0
  57. package/src/components/Button/__snapshots__/Button.test.tsx.snap +9 -0
  58. package/src/components/Checkbox/Checkbox.test.tsx +71 -43
  59. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +17 -0
  60. package/src/components/{Circular_Progress → CircularProgress}/CircularProgress.tsx +1 -1
  61. package/src/components/Divider/Divider.test.tsx +35 -10
  62. package/src/components/InputTextField/InputTextField.test.tsx +103 -33
  63. package/src/components/InputTextField/InputTextField.tsx +7 -5
  64. package/src/components/Link/Link.test.tsx +44 -36
  65. package/src/components/Link/Link.tsx +1 -1
  66. package/src/components/Map/Directions.tsx +36 -0
  67. package/src/components/Map/GoogleMap.module.scss +5 -0
  68. package/src/components/Map/GoogleMap.tsx +186 -0
  69. package/src/components/Map/GoogleMapsLoader.tsx +12 -0
  70. package/src/components/Map/index.ts +2 -0
  71. package/src/components/Modal/Modal.css +26 -0
  72. package/src/components/Modal/Modal.test.tsx +53 -34
  73. package/src/components/Modal/Modal.tsx +15 -6
  74. package/src/components/PdfView/PdfView.css +70 -0
  75. package/src/components/PdfView/PdfView.test.tsx +27 -63
  76. package/src/components/PdfView/PdfView.tsx +53 -41
  77. package/src/components/Progress/Progress.test.tsx +34 -26
  78. package/src/components/Progress/Progress.tsx +2 -2
  79. package/src/components/RadioButton/RadioButton.test.tsx +59 -30
  80. package/src/components/Switch/Switch.test.tsx +83 -0
  81. package/src/components/Tag/Tag.test.tsx +57 -0
  82. package/src/components/Tag/__snapshots__/Tag.test.tsx.snap +9 -0
  83. package/src/components/Tooltip/Tooltip.test.tsx +73 -0
  84. package/src/components/Tooltip/__snapshots__/Tooltip.test.tsx.snap +22 -0
  85. package/src/components/index.ts +5 -2
  86. package/src/typings.d.ts +1 -0
  87. package/tsconfig.json +17 -18
  88. /package/src/components/{Circular_Progress → CircularProgress}/CircularProgress.css +0 -0
  89. /package/src/components/{Circular_Progress → CircularProgress}/CircularProgress.test.tsx +0 -0
  90. /package/src/components/{Circular_Progress → CircularProgress}/index.ts +0 -0
@@ -0,0 +1,457 @@
1
+ TN:
2
+ SF:src/components/Enum.ts
3
+ FNF:0
4
+ FNH:0
5
+ DA:1,3
6
+ DA:9,3
7
+ DA:14,3
8
+ LF:3
9
+ LH:3
10
+ BRF:0
11
+ BRH:0
12
+ end_of_record
13
+ TN:
14
+ SF:src/components/Avatar/Avatar.tsx
15
+ FN:10,(anonymous_1)
16
+ FNF:1
17
+ FNH:1
18
+ FNDA:5,(anonymous_1)
19
+ DA:1,1
20
+ DA:10,1
21
+ DA:16,5
22
+ DA:26,1
23
+ LF:4
24
+ LH:4
25
+ BRF:0
26
+ BRH:0
27
+ end_of_record
28
+ TN:
29
+ SF:src/components/Badge/Badge.tsx
30
+ FN:10,(anonymous_1)
31
+ FNF:1
32
+ FNH:1
33
+ FNDA:6,(anonymous_1)
34
+ DA:1,1
35
+ DA:2,1
36
+ DA:10,1
37
+ DA:15,6
38
+ DA:25,1
39
+ LF:5
40
+ LH:5
41
+ BRF:0
42
+ BRH:0
43
+ end_of_record
44
+ TN:
45
+ SF:src/components/BreadCrumb/BreadCrumb.tsx
46
+ FN:17,(anonymous_1)
47
+ FN:26,(anonymous_2)
48
+ FNF:2
49
+ FNH:2
50
+ FNDA:3,(anonymous_1)
51
+ FNDA:7,(anonymous_2)
52
+ DA:1,1
53
+ DA:2,1
54
+ DA:17,1
55
+ DA:24,3
56
+ DA:27,7
57
+ DA:36,1
58
+ LF:6
59
+ LH:6
60
+ BRDA:21,0,0,0
61
+ BRDA:29,1,0,7
62
+ BRDA:29,1,1,4
63
+ BRF:3
64
+ BRH:2
65
+ end_of_record
66
+ TN:
67
+ SF:src/components/Button/Button.tsx
68
+ FN:10,(anonymous_1)
69
+ FNF:1
70
+ FNH:1
71
+ FNDA:5,(anonymous_1)
72
+ DA:1,1
73
+ DA:2,1
74
+ DA:10,1
75
+ DA:15,5
76
+ DA:22,1
77
+ LF:5
78
+ LH:5
79
+ BRF:0
80
+ BRH:0
81
+ end_of_record
82
+ TN:
83
+ SF:src/components/Checkbox/Checkbox.tsx
84
+ FN:12,(anonymous_2)
85
+ FNF:1
86
+ FNH:1
87
+ FNDA:7,(anonymous_2)
88
+ DA:1,1
89
+ DA:12,1
90
+ DA:18,7
91
+ DA:19,7
92
+ DA:21,7
93
+ DA:35,1
94
+ LF:6
95
+ LH:6
96
+ BRDA:14,0,0,0
97
+ BRDA:16,1,0,0
98
+ BRDA:17,2,0,0
99
+ BRDA:18,3,0,0
100
+ BRDA:30,4,0,7
101
+ BRDA:30,4,1,7
102
+ BRF:6
103
+ BRH:2
104
+ end_of_record
105
+ TN:
106
+ SF:src/components/CircularProgress/CircularProgress.tsx
107
+ FN:12,(anonymous_1)
108
+ FNF:1
109
+ FNH:1
110
+ FNDA:4,(anonymous_1)
111
+ DA:1,1
112
+ DA:2,1
113
+ DA:12,1
114
+ DA:19,4
115
+ DA:20,4
116
+ DA:24,4
117
+ DA:37,1
118
+ LF:7
119
+ LH:7
120
+ BRDA:13,0,0,3
121
+ BRDA:14,1,0,3
122
+ BRDA:15,2,0,3
123
+ BRDA:16,3,0,3
124
+ BRDA:17,4,0,2
125
+ BRDA:20,5,0,1
126
+ BRDA:20,5,1,3
127
+ BRDA:28,6,0,3
128
+ BRDA:28,6,1,1
129
+ BRDA:29,7,0,3
130
+ BRDA:29,7,1,1
131
+ BRF:11
132
+ BRH:11
133
+ end_of_record
134
+ TN:
135
+ SF:src/components/Divider/Divider.tsx
136
+ FN:11,(anonymous_2)
137
+ FNF:1
138
+ FNH:1
139
+ FNDA:6,(anonymous_2)
140
+ DA:1,1
141
+ DA:2,1
142
+ DA:11,1
143
+ DA:14,6
144
+ DA:15,6
145
+ DA:17,6
146
+ DA:24,1
147
+ LF:7
148
+ LH:7
149
+ BRDA:12,0,0,5
150
+ BRDA:13,1,0,5
151
+ BRDA:14,2,0,5
152
+ BRF:3
153
+ BRH:3
154
+ end_of_record
155
+ TN:
156
+ SF:src/components/InputTextField/InputTextField.tsx
157
+ FN:19,(anonymous_2)
158
+ FNF:1
159
+ FNH:1
160
+ FNDA:10,(anonymous_2)
161
+ DA:1,1
162
+ DA:2,1
163
+ DA:19,1
164
+ DA:29,10
165
+ DA:30,10
166
+ DA:32,10
167
+ DA:48,1
168
+ LF:7
169
+ LH:7
170
+ BRDA:21,0,0,0
171
+ BRDA:22,1,0,0
172
+ BRDA:23,2,0,4
173
+ BRDA:25,3,0,4
174
+ BRDA:26,4,0,4
175
+ BRDA:27,5,0,4
176
+ BRDA:28,6,0,4
177
+ BRDA:29,7,0,4
178
+ BRDA:34,8,0,10
179
+ BRDA:34,8,1,10
180
+ BRDA:43,9,0,10
181
+ BRDA:43,9,1,1
182
+ BRF:12
183
+ BRH:10
184
+ end_of_record
185
+ TN:
186
+ SF:src/components/Link/Link.tsx
187
+ FN:12,(anonymous_2)
188
+ FNF:1
189
+ FNH:1
190
+ FNDA:7,(anonymous_2)
191
+ DA:1,1
192
+ DA:2,1
193
+ DA:12,1
194
+ DA:17,7
195
+ DA:18,7
196
+ DA:20,7
197
+ DA:33,1
198
+ LF:7
199
+ LH:7
200
+ BRDA:14,0,0,1
201
+ BRDA:16,1,0,0
202
+ BRF:2
203
+ BRH:1
204
+ end_of_record
205
+ TN:
206
+ SF:src/components/Modal/Modal.tsx
207
+ FN:12,(anonymous_1)
208
+ FN:15,(anonymous_2)
209
+ FNF:2
210
+ FNH:2
211
+ FNDA:7,(anonymous_1)
212
+ FNDA:2,(anonymous_2)
213
+ DA:1,1
214
+ DA:2,1
215
+ DA:12,1
216
+ DA:13,7
217
+ DA:15,5
218
+ DA:16,2
219
+ DA:17,1
220
+ DA:21,5
221
+ DA:28,1
222
+ LF:9
223
+ LH:9
224
+ BRDA:13,0,0,2
225
+ BRDA:16,1,0,1
226
+ BRF:2
227
+ BRH:2
228
+ end_of_record
229
+ TN:
230
+ SF:src/components/Notification/Notification.tsx
231
+ FN:10,(anonymous_6)
232
+ FN:16,(anonymous_7)
233
+ FN:18,(anonymous_8)
234
+ FN:22,(anonymous_9)
235
+ FN:26,(anonymous_10)
236
+ FN:33,(anonymous_11)
237
+ FN:35,(anonymous_12)
238
+ FNF:7
239
+ FNH:7
240
+ FNDA:4,(anonymous_6)
241
+ FNDA:4,(anonymous_7)
242
+ FNDA:1,(anonymous_8)
243
+ FNDA:3,(anonymous_9)
244
+ FNDA:3,(anonymous_10)
245
+ FNDA:2,(anonymous_11)
246
+ FNDA:1,(anonymous_12)
247
+ DA:1,1
248
+ DA:2,1
249
+ DA:10,1
250
+ DA:16,4
251
+ DA:17,4
252
+ DA:18,3
253
+ DA:19,1
254
+ DA:22,3
255
+ DA:26,4
256
+ DA:27,3
257
+ DA:28,3
258
+ DA:32,4
259
+ DA:33,2
260
+ DA:35,1
261
+ DA:42,1
262
+ LF:15
263
+ LH:15
264
+ BRDA:12,0,0,0
265
+ BRDA:13,1,0,1
266
+ BRDA:17,2,0,3
267
+ BRDA:17,3,0,4
268
+ BRDA:17,3,1,4
269
+ BRDA:27,4,0,3
270
+ BRF:6
271
+ BRH:5
272
+ end_of_record
273
+ TN:
274
+ SF:src/components/PdfView/PdfView.tsx
275
+ FN:21,(anonymous_13)
276
+ FN:41,(anonymous_14)
277
+ FN:47,(anonymous_15)
278
+ FN:64,(anonymous_16)
279
+ FN:64,(anonymous_17)
280
+ FN:73,(anonymous_18)
281
+ FNF:6
282
+ FNH:2
283
+ FNDA:4,(anonymous_13)
284
+ FNDA:3,(anonymous_14)
285
+ FNDA:0,(anonymous_15)
286
+ FNDA:0,(anonymous_16)
287
+ FNDA:0,(anonymous_17)
288
+ FNDA:0,(anonymous_18)
289
+ DA:1,1
290
+ DA:2,1
291
+ DA:21,1
292
+ DA:37,4
293
+ DA:38,4
294
+ DA:39,4
295
+ DA:41,4
296
+ DA:42,3
297
+ DA:43,1
298
+ DA:47,4
299
+ DA:48,0
300
+ DA:49,0
301
+ DA:50,0
302
+ DA:52,0
303
+ DA:53,0
304
+ DA:56,0
305
+ DA:58,0
306
+ DA:59,0
307
+ DA:60,0
308
+ DA:64,4
309
+ DA:65,0
310
+ DA:66,0
311
+ DA:67,0
312
+ DA:68,0
313
+ DA:69,0
314
+ DA:71,0
315
+ DA:73,0
316
+ DA:74,0
317
+ DA:76,0
318
+ DA:78,0
319
+ DA:79,0
320
+ DA:80,0
321
+ DA:84,4
322
+ DA:105,1
323
+ LF:34
324
+ LH:13
325
+ BRDA:23,0,0,4
326
+ BRDA:24,1,0,4
327
+ BRDA:25,2,0,4
328
+ BRDA:26,3,0,4
329
+ BRDA:28,4,0,4
330
+ BRDA:29,5,0,4
331
+ BRDA:30,6,0,4
332
+ BRDA:31,7,0,4
333
+ BRDA:32,8,0,4
334
+ BRDA:33,9,0,4
335
+ BRDA:34,10,0,4
336
+ BRDA:42,11,0,1
337
+ BRDA:47,12,0,0
338
+ BRDA:68,13,0,0
339
+ BRDA:68,13,1,0
340
+ BRDA:86,14,0,4
341
+ BRDA:86,14,1,0
342
+ BRDA:86,14,2,0
343
+ BRDA:91,15,0,4
344
+ BRDA:91,15,1,1
345
+ BRDA:92,16,0,4
346
+ BRDA:92,16,1,4
347
+ BRDA:92,16,2,3
348
+ BRDA:100,17,0,4
349
+ BRDA:100,17,1,0
350
+ BRDA:100,17,2,0
351
+ BRF:26
352
+ BRH:19
353
+ end_of_record
354
+ TN:
355
+ SF:src/components/Progress/Progress.tsx
356
+ FN:13,(anonymous_2)
357
+ FNF:1
358
+ FNH:1
359
+ FNDA:6,(anonymous_2)
360
+ DA:1,1
361
+ DA:13,1
362
+ DA:20,6
363
+ DA:21,6
364
+ DA:23,6
365
+ DA:25,6
366
+ DA:35,1
367
+ LF:7
368
+ LH:7
369
+ BRDA:16,0,0,6
370
+ BRDA:17,1,0,6
371
+ BRDA:18,2,0,2
372
+ BRDA:19,3,0,5
373
+ BRDA:27,4,0,6
374
+ BRDA:27,4,1,1
375
+ BRF:6
376
+ BRH:6
377
+ end_of_record
378
+ TN:
379
+ SF:src/components/RadioButton/RadioButton.tsx
380
+ FN:15,(anonymous_2)
381
+ FNF:1
382
+ FNH:1
383
+ FNDA:4,(anonymous_2)
384
+ DA:1,1
385
+ DA:15,1
386
+ DA:23,4
387
+ DA:24,3
388
+ DA:26,3
389
+ DA:43,1
390
+ LF:6
391
+ LH:6
392
+ BRDA:18,0,0,2
393
+ BRDA:20,1,0,2
394
+ BRDA:21,2,0,2
395
+ BRDA:22,3,0,2
396
+ BRF:4
397
+ BRH:4
398
+ end_of_record
399
+ TN:
400
+ SF:src/components/Switch/Switch.tsx
401
+ FN:14,(anonymous_1)
402
+ FNF:1
403
+ FNH:1
404
+ FNDA:5,(anonymous_1)
405
+ DA:1,1
406
+ DA:2,1
407
+ DA:14,1
408
+ DA:23,5
409
+ DA:38,1
410
+ LF:5
411
+ LH:5
412
+ BRDA:25,0,0,5
413
+ BRDA:25,0,1,2
414
+ BRF:2
415
+ BRH:2
416
+ end_of_record
417
+ TN:
418
+ SF:src/components/Tag/Tag.tsx
419
+ FN:10,(anonymous_1)
420
+ FNF:1
421
+ FNH:1
422
+ FNDA:5,(anonymous_1)
423
+ DA:1,1
424
+ DA:2,1
425
+ DA:10,1
426
+ DA:15,5
427
+ DA:25,1
428
+ LF:5
429
+ LH:5
430
+ BRF:0
431
+ BRH:0
432
+ end_of_record
433
+ TN:
434
+ SF:src/components/Tooltip/Tooltip.tsx
435
+ FN:11,(anonymous_6)
436
+ FN:19,(anonymous_7)
437
+ FN:20,(anonymous_8)
438
+ FNF:3
439
+ FNH:3
440
+ FNDA:9,(anonymous_6)
441
+ FNDA:2,(anonymous_7)
442
+ FNDA:1,(anonymous_8)
443
+ DA:1,1
444
+ DA:2,1
445
+ DA:11,1
446
+ DA:17,9
447
+ DA:19,9
448
+ DA:20,9
449
+ DA:22,9
450
+ DA:34,1
451
+ LF:8
452
+ LH:8
453
+ BRDA:25,0,0,9
454
+ BRDA:25,0,1,2
455
+ BRF:2
456
+ BRH:2
457
+ end_of_record
package/jest.config.ts CHANGED
@@ -6,5 +6,5 @@ module.exports = {
6
6
  moduleNameMapper: {
7
7
  '\\.(css|less|sass|scss)$': '<rootDir>/src/__mocks__/styleMock.js', // Mock CSS files
8
8
  },
9
- };
9
+ };
10
10
 
package/package.json CHANGED
@@ -1,21 +1,25 @@
1
1
  {
2
2
  "name": "dhre-component-lib",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "test": "jest",
7
- "rollup": "rollup -c"
7
+ "rollup": "rollup -c",
8
+ "test:coverage": "jest --coverage"
8
9
  },
9
10
  "author": "",
10
11
  "license": "ISC",
11
12
  "description": "",
12
13
  "devDependencies": {
14
+ "@babel/core": "^7.25.2",
15
+ "@babel/preset-env": "^7.25.4",
13
16
  "@rollup/plugin-commonjs": "^26.0.1",
14
17
  "@rollup/plugin-node-resolve": "^15.2.3",
15
18
  "@rollup/plugin-typescript": "^11.1.6",
16
- "@testing-library/jest-dom": "^6.4.8",
19
+ "@testing-library/jest-dom": "^6.5.0",
20
+ "@testing-library/react": "^16.0.1",
17
21
  "@types/jest": "^29.5.12",
18
- "@types/react": "^18.3.3",
22
+ "@types/react": "^18.3.5",
19
23
  "@types/testing-library__jest-dom": "^6.0.0",
20
24
  "jest": "^29.7.0",
21
25
  "jest-dom": "^4.0.0",
@@ -25,7 +29,7 @@
25
29
  "rollup": "^4.18.1",
26
30
  "rollup-plugin-dts": "^6.1.1",
27
31
  "rollup-plugin-peer-deps-external": "^2.2.4",
28
- "ts-jest": "^29.2.4",
32
+ "ts-jest": "^29.2.5",
29
33
  "ts-node": "^10.9.2",
30
34
  "typescript": "^5.5.3"
31
35
  },
@@ -34,7 +38,6 @@
34
38
  "@emotion/styled": "^11.13.0",
35
39
  "@mui/icons-material": "^5.16.7",
36
40
  "@mui/material": "^5.16.7",
37
- "@testing-library/react": "^16.0.0",
38
41
  "tslib": "^2.6.3"
39
42
  },
40
43
  "peerDependencies": {
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import Avatar, { AvatarProps } from './Avatar';
5
+
6
+ describe('Avatar Component', () => {
7
+ const defaultProps: AvatarProps = {
8
+ src: 'test-image.jpg',
9
+ alt: 'Test Avatar',
10
+ imgClassName: 'avatar-class',
11
+ };
12
+
13
+ it('renders the image with the provided src and alt attributes', () => {
14
+ render(<Avatar {...defaultProps} />);
15
+
16
+ const imgElement = screen.getByAltText(defaultProps.alt);
17
+
18
+ expect(imgElement).toHaveAttribute('src', defaultProps.src);
19
+ expect(imgElement).toHaveAttribute('alt', defaultProps.alt);
20
+ });
21
+
22
+ it('applies the correct className to the image', () => {
23
+ render(<Avatar {...defaultProps} />);
24
+
25
+ const imgElement = screen.getByAltText(defaultProps.alt);
26
+
27
+ expect(imgElement).toHaveClass(defaultProps.imgClassName);
28
+ });
29
+
30
+ it('handles the onClick event correctly', () => {
31
+ const handleClick = jest.fn();
32
+ render(<Avatar {...defaultProps} handleClick={handleClick} />);
33
+
34
+ const imgElement = screen.getByAltText(defaultProps.alt);
35
+ fireEvent.click(imgElement);
36
+
37
+ expect(handleClick).toHaveBeenCalledTimes(1);
38
+ });
39
+
40
+ it('does not crash without handleClick prop', () => {
41
+ render(<Avatar {...defaultProps} />);
42
+
43
+ const imgElement = screen.getByAltText(defaultProps.alt);
44
+ expect(() => fireEvent.click(imgElement)).not.toThrow();
45
+ });
46
+
47
+ it('matches snapshot for default rendering', () => {
48
+ const { container } = render(<Avatar {...defaultProps} />);
49
+
50
+ expect(container.firstChild).toMatchSnapshot();
51
+ });
52
+ });
@@ -0,0 +1,9 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Avatar Component matches snapshot for default rendering 1`] = `
4
+ <img
5
+ alt="Test Avatar"
6
+ class="avatar-class"
7
+ src="test-image.jpg"
8
+ />
9
+ `;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent, waitFor } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import Badge, { BadgeProps } from './Badge';
5
+
6
+ describe('Badge Component', () => {
7
+ const defaultProps: BadgeProps = {
8
+ content: 'Test Badge',
9
+ badgeClassName: 'badge-class',
10
+ };
11
+
12
+ it('renders the badge with the provided content', () => {
13
+ render(<Badge {...defaultProps} />);
14
+
15
+ const badgeElement = screen.getByText(defaultProps.content as string);
16
+
17
+ expect(badgeElement).toBeInTheDocument();
18
+ });
19
+
20
+ it('applies the correct className to the badge', () => {
21
+ render(<Badge {...defaultProps} />);
22
+
23
+ const badgeElement = screen.getByText(defaultProps.content as string);
24
+
25
+ expect(badgeElement).toHaveClass(defaultProps.badgeClassName);
26
+ });
27
+
28
+ it('handles the onClick event correctly', () => {
29
+ const handleClick = jest.fn();
30
+ render(<Badge {...defaultProps} handleClick={handleClick} />);
31
+
32
+ const badgeElement = screen.getByText(defaultProps.content as string);
33
+ fireEvent.click(badgeElement);
34
+
35
+ expect(handleClick).toHaveBeenCalledTimes(1);
36
+ });
37
+
38
+ it('does not crash without handleClick prop', () => {
39
+ render(<Badge {...defaultProps} />);
40
+
41
+ const badgeElement = screen.getByText(defaultProps.content as string);
42
+ expect(() => fireEvent.click(badgeElement)).not.toThrow();
43
+ });
44
+
45
+ it('renders correctly with numeric content', () => {
46
+ const numericProps: BadgeProps = {
47
+ ...defaultProps,
48
+ content: 99,
49
+ };
50
+ render(<Badge {...numericProps} />);
51
+
52
+ const badgeElement = screen.getByText(numericProps.content.toString());
53
+
54
+ expect(badgeElement).toBeInTheDocument();
55
+ expect(badgeElement).toHaveTextContent('99');
56
+ });
57
+
58
+ it('matches snapshot for default rendering', () => {
59
+ const { container } = render(<Badge {...defaultProps} />);
60
+
61
+ expect(container.firstChild).toMatchSnapshot();
62
+ });
63
+ });
@@ -0,0 +1,9 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Badge Component matches snapshot for default rendering 1`] = `
4
+ <span
5
+ class="badge-class"
6
+ >
7
+ Test Badge
8
+ </span>
9
+ `;