@transferwise/components 0.0.0-experimental-029bd71 → 0.0.0-experimental-339e531

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 (66) hide show
  1. package/build/button/Button.js.map +1 -1
  2. package/build/button/Button.mjs.map +1 -1
  3. package/build/button/legacyUtils/legacyUtils.js.map +1 -1
  4. package/build/button/legacyUtils/legacyUtils.mjs.map +1 -1
  5. package/build/i18n/en.json +0 -5
  6. package/build/i18n/en.json.js +0 -5
  7. package/build/i18n/en.json.js.map +1 -1
  8. package/build/i18n/en.json.mjs +0 -5
  9. package/build/i18n/en.json.mjs.map +1 -1
  10. package/build/main.css +0 -300
  11. package/build/styles/main.css +0 -300
  12. package/build/types/button/Button.d.ts +1 -1
  13. package/build/types/button/Button.d.ts.map +1 -1
  14. package/build/types/button/legacyUtils/legacyUtils.d.ts +2 -2
  15. package/build/types/button/legacyUtils/legacyUtils.d.ts.map +1 -1
  16. package/build/types/test-utils/index.d.ts +158 -0
  17. package/build/types/test-utils/index.d.ts.map +1 -0
  18. package/build/types/test-utils/jest.setup.d.ts +2 -0
  19. package/build/types/test-utils/jest.setup.d.ts.map +1 -0
  20. package/package.json +4 -3
  21. package/src/button/{Button.spec.js → Button.spec.tsx} +3 -2
  22. package/src/button/Button.tsx +1 -1
  23. package/src/button/legacyUtils/{legacyUtils.spec.js → legacyUtils.spec.tsx} +1 -1
  24. package/src/button/legacyUtils/legacyUtils.ts +2 -2
  25. package/src/i18n/en.json +0 -5
  26. package/src/main.css +0 -300
  27. package/src/main.less +0 -1
  28. package/src/modal/{Modal.rtl.spec.js → Modal.rtl.spec.tsx} +8 -7
  29. package/src/slidingPanel/SlidingPanel.spec.js +1 -1
  30. package/src/ssr.spec.tsx +264 -0
  31. package/src/test-utils/{index.js → index.tsx} +11 -6
  32. package/src/test-utils/{jest.setup.js → jest.setup.ts} +13 -8
  33. package/build/styles/table/Table.css +0 -300
  34. package/build/types/table/Table.d.ts +0 -23
  35. package/build/types/table/Table.d.ts.map +0 -1
  36. package/build/types/table/Table.messages.d.ts +0 -24
  37. package/build/types/table/Table.messages.d.ts.map +0 -1
  38. package/build/types/table/TableCell.d.ts +0 -44
  39. package/build/types/table/TableCell.d.ts.map +0 -1
  40. package/build/types/table/TableHeader.d.ts +0 -13
  41. package/build/types/table/TableHeader.d.ts.map +0 -1
  42. package/build/types/table/TableRow.d.ts +0 -17
  43. package/build/types/table/TableRow.d.ts.map +0 -1
  44. package/build/types/table/TableStatusText.d.ts +0 -9
  45. package/build/types/table/TableStatusText.d.ts.map +0 -1
  46. package/build/types/table/index.d.ts +0 -6
  47. package/build/types/table/index.d.ts.map +0 -1
  48. package/src/ssr.spec.js +0 -256
  49. package/src/table/Table.css +0 -300
  50. package/src/table/Table.less +0 -361
  51. package/src/table/Table.messages.ts +0 -24
  52. package/src/table/Table.spec.tsx +0 -88
  53. package/src/table/Table.story.tsx +0 -359
  54. package/src/table/Table.tsx +0 -166
  55. package/src/table/TableCell.spec.tsx +0 -304
  56. package/src/table/TableCell.tsx +0 -170
  57. package/src/table/TableHeader.spec.tsx +0 -55
  58. package/src/table/TableHeader.tsx +0 -75
  59. package/src/table/TableRow.spec.tsx +0 -117
  60. package/src/table/TableRow.tsx +0 -70
  61. package/src/table/TableStatusText.spec.tsx +0 -53
  62. package/src/table/TableStatusText.tsx +0 -36
  63. package/src/table/index.ts +0 -11
  64. /package/src/button/__snapshots__/{Button.spec.js.snap → Button.spec.tsx.snap} +0 -0
  65. /package/src/dimmer/{Dimmer.rtl.spec.js → Dimmer.rtl.spec.tsx} +0 -0
  66. /package/src/info/{Info.spec.js → Info.spec.jsx} +0 -0
package/src/main.css CHANGED
@@ -5052,306 +5052,6 @@ html:not([dir="rtl"]) .np-navigation-option {
5052
5052
  padding: 0 var(--size-24);
5053
5053
  }
5054
5054
  }
5055
- .np-table {
5056
- width: 100%;
5057
- background-color: transparent;
5058
- }
5059
- .np-table-outer-container {
5060
- border-radius: 16px;
5061
- border-radius: var(--radius-medium);
5062
- }
5063
- .np-table-outer-container:focus {
5064
- outline: none;
5065
- }
5066
- .np-table-outer-container:focus-visible {
5067
- outline: var(--ring-outline-color) solid var(--ring-outline-width);
5068
- outline-offset: var(--ring-outline-offset);
5069
- }
5070
- .np-table-outer-container:focus-visible {
5071
- outline-offset: 0;
5072
- }
5073
- .np-table-outer-container--center {
5074
- margin-right: auto;
5075
- margin-left: auto;
5076
- }
5077
- @media (max-width: 767px) {
5078
- .np-table-outer-container--center {
5079
- width: 100%;
5080
- }
5081
- }
5082
- .np-table-outer-container--full-width {
5083
- width: 100%;
5084
- }
5085
- .np-table-container {
5086
- padding: 8px;
5087
- padding: var(--size-8);
5088
- background-color: rgba(134,167,189,0.10196);
5089
- background-color: var(--color-background-neutral);
5090
- border-radius: inherit;
5091
- }
5092
- .np-table-container--loading .np-table-inner-container {
5093
- background-image: none;
5094
- }
5095
- .np-table-inner-container {
5096
- background-image: linear-gradient(to right, var(--color-contrast-overlay), var(--color-contrast-overlay)), linear-gradient(to right, var(--color-contrast-overlay), var(--color-contrast-overlay)), linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0)), linear-gradient(to left, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0));
5097
- background-position: left center, right center, left center, right center;
5098
- background-repeat: no-repeat;
5099
- background-color: var(--color-contrast-overlay);
5100
- background-size: 15px 100%, 15px 100%, 15px 100%, 15px 100%;
5101
- background-attachment: local, local, scroll, scroll;
5102
- overflow-x: auto;
5103
- border-radius: 10px;
5104
- }
5105
- .np-theme-personal--dark .np-table-inner-container {
5106
- background-image: linear-gradient(to right, var(--color-contrast-overlay), var(--color-contrast-overlay)), linear-gradient(to right, var(--color-contrast-overlay), var(--color-contrast-overlay)), linear-gradient(to right, #000000, rgba(0, 0, 0, 0)), linear-gradient(to left, #000000, rgba(0, 0, 0, 0));
5107
- }
5108
- .np-table-row:last-child .np-table-cell:first-child {
5109
- border-bottom-left-radius: 10px;
5110
- }
5111
- .np-table-row:last-child .np-table-cell:last-child {
5112
- border-bottom-right-radius: 10px;
5113
- }
5114
- .np-table-row:focus {
5115
- outline: none;
5116
- }
5117
- .np-table-row:focus-visible {
5118
- outline: var(--ring-outline-color) solid var(--ring-outline-width);
5119
- outline-offset: var(--ring-outline-offset);
5120
- }
5121
- .np-table-row:focus-visible {
5122
- outline-offset: -2px;
5123
- border-radius: 6px;
5124
- }
5125
- .np-table-row--clickable .np-table-cell {
5126
- position: relative;
5127
- }
5128
- .np-table-row--clickable .np-table-cell:before {
5129
- display: none;
5130
- content: "";
5131
- position: absolute;
5132
- height: 100%;
5133
- width: 100%;
5134
- top: 0;
5135
- left: 0;
5136
- background-color: var(--color-background-screen-hover);
5137
- }
5138
- .np-table-row--clickable .np-table-cell:first-child:before,
5139
- .np-table-row--clickable .np-table-cell:last-child:before {
5140
- width: calc(100% - 8px);
5141
- width: calc(100% - var(--size-8));
5142
- }
5143
- .np-table-row--clickable .np-table-cell:first-child:before {
5144
- left: 8px;
5145
- left: var(--size-8);
5146
- border-top-left-radius: 6px;
5147
- border-bottom-left-radius: 6px;
5148
- }
5149
- .np-table-row--clickable .np-table-cell:last-child:before {
5150
- border-top-right-radius: 6px;
5151
- border-bottom-right-radius: 6px;
5152
- }
5153
- .np-table-row--clickable:hover .np-table-cell:before {
5154
- display: block;
5155
- }
5156
- .np-table-row--clickable:hover:focus-visible .np-table-cell:first-child:before,
5157
- .np-table-row--clickable:hover:focus-visible .np-table-cell:last-child:before {
5158
- width: 100%;
5159
- }
5160
- .np-table-row--clickable:hover:focus-visible .np-table-cell:first-child:before {
5161
- left: 0;
5162
- }
5163
- .np-table-row--cosmetic .np-table-cell {
5164
- height: 8px;
5165
- height: var(--size-8);
5166
- padding: 0;
5167
- }
5168
- .np-table-header,
5169
- .np-table-cell {
5170
- padding: 0;
5171
- }
5172
- .np-table-header:first-child,
5173
- .np-table-cell:first-child {
5174
- padding-left: 16px;
5175
- padding-left: var(--size-16);
5176
- }
5177
- .np-table-header:first-child .np-table-header-content,
5178
- .np-table-cell:first-child .np-table-header-content,
5179
- .np-table-header:first-child .np-table-cell-content,
5180
- .np-table-cell:first-child .np-table-cell-content {
5181
- padding-left: 0;
5182
- }
5183
- .np-table-header:last-child,
5184
- .np-table-cell:last-child {
5185
- padding-right: 16px;
5186
- padding-right: var(--size-16);
5187
- }
5188
- .np-table-header:last-child .np-table-header-content,
5189
- .np-table-cell:last-child .np-table-header-content,
5190
- .np-table-header:last-child .np-table-cell-content,
5191
- .np-table-cell:last-child .np-table-cell-content {
5192
- padding-right: 0;
5193
- }
5194
- .np-table-header .np-table-text-secondary,
5195
- .np-table-cell .np-table-text-secondary {
5196
- color: #768e9c;
5197
- color: var(--color-content-tertiary);
5198
- font-size: 0.75rem;
5199
- font-size: var(--font-size-12);
5200
- font-style: normal;
5201
- font-weight: 400;
5202
- font-weight: var(--font-weight-regular);
5203
- line-height: 1.125rem;
5204
- line-height: var(--line-height-18);
5205
- }
5206
- .np-table-header.np-table-header--right > .np-text-body-default,
5207
- .np-table-cell.np-table-cell--right > .np-text-body-default {
5208
- text-align: right;
5209
- }
5210
- .np-table-header.np-table-header--right + .np-table-header:not(.np-table-header--right),
5211
- .np-table-cell.np-table-cell--right + .np-table-cell:not(.np-table-cell--right) {
5212
- padding-left: calc(8px + 12px);
5213
- padding-left: calc(var(--size-8) + var(--size-12));
5214
- }
5215
- .np-table-header.np-table-header--right .np-table-header-content,
5216
- .np-table-cell.np-table-cell--right .np-table-content {
5217
- justify-content: end;
5218
- }
5219
- .np-table-header-content,
5220
- .np-table-content {
5221
- display: flex;
5222
- align-items: center;
5223
- justify-content: start;
5224
- }
5225
- .np-table-header {
5226
- min-width: 160px;
5227
- padding-right: 8px;
5228
- padding-right: var(--size-8);
5229
- padding-bottom: 8px;
5230
- padding-bottom: var(--size-8);
5231
- padding-left: 8px;
5232
- padding-left: var(--size-8);
5233
- background-color: rgba(134,167,189,0.10196);
5234
- background-color: var(--color-background-neutral);
5235
- color: var(--color-interactive-primary);
5236
- }
5237
- .np-table-header-content {
5238
- padding-top: 5px;
5239
- padding-bottom: 5px;
5240
- white-space: nowrap;
5241
- line-height: 1.375rem;
5242
- line-height: var(--line-height-22);
5243
- letter-spacing: 0.0125em;
5244
- letter-spacing: var(--letter-spacing-sm);
5245
- }
5246
- .np-table-header--error {
5247
- color: var(--color-sentiment-negative);
5248
- }
5249
- .np-table-header--action {
5250
- min-width: 0;
5251
- padding: 0;
5252
- }
5253
- .np-table-cell {
5254
- padding: 16px 8px;
5255
- padding: var(--size-16) var(--size-8);
5256
- position: relative;
5257
- }
5258
- .np-table-cell--cosmetic {
5259
- padding: 0;
5260
- }
5261
- .np-table-cell--primary {
5262
- min-width: 200px;
5263
- }
5264
- .np-table-cell--currency .np-text-body-default {
5265
- white-space: nowrap;
5266
- }
5267
- .np-table-cell--status .status-circle {
5268
- width: 24px;
5269
- height: 24px;
5270
- }
5271
- .np-table-cell--status .status-circle .status-icon > svg {
5272
- width: 21px;
5273
- height: 21px;
5274
- }
5275
- .np-table-cell .tw-chevron {
5276
- margin-left: 8px;
5277
- margin-left: var(--size-8);
5278
- }
5279
- .np-table-cell-separator {
5280
- margin-top: 4px;
5281
- margin-top: var(--size-4);
5282
- margin-bottom: 4px;
5283
- margin-bottom: var(--size-4);
5284
- height: 1px;
5285
- background-color: rgba(134,167,189,0.10196);
5286
- background-color: var(--color-background-neutral);
5287
- padding: 0;
5288
- }
5289
- .np-table-cell .np-text-body-default {
5290
- line-height: 1.375rem;
5291
- line-height: var(--line-height-22);
5292
- letter-spacing: 0.01em;
5293
- letter-spacing: var(--letter-spacing-xs);
5294
- }
5295
- .np-table-cell .np-text-body-default-bold {
5296
- display: flex;
5297
- align-items: center;
5298
- color: #37517e;
5299
- color: var(--color-content-primary);
5300
- white-space: nowrap;
5301
- }
5302
- .np-table-cell .np-table-content--success {
5303
- color: var(--color-sentiment-positive);
5304
- }
5305
- .np-table-cell .np-table-content--error {
5306
- color: var(--color-sentiment-negative);
5307
- }
5308
- .np-table-cell .tw-loader {
5309
- margin: 150px auto;
5310
- }
5311
- @media (max-width: 320px) {
5312
- .np-table-cell .tw-loader {
5313
- margin-top: 70px;
5314
- margin-bottom: 70px;
5315
- }
5316
- }
5317
- .np-table-content {
5318
- gap: 12px;
5319
- gap: var(--size-12);
5320
- }
5321
- .np-table-content--success,
5322
- .np-table-content--error {
5323
- gap: 4px;
5324
- gap: var(--size-4);
5325
- }
5326
- .np-table-content--success .np-table-content-text,
5327
- .np-table-content--error .np-table-content-text {
5328
- line-height: 155%;
5329
- }
5330
- .np-table-content-media {
5331
- flex-shrink: 0;
5332
- }
5333
- .np-table-content-body {
5334
- display: flex;
5335
- flex-direction: column;
5336
- font-size: 0.75rem;
5337
- font-size: var(--font-size-12);
5338
- color: #768e9c;
5339
- color: var(--color-content-tertiary);
5340
- }
5341
- .np-table-content--reversed {
5342
- flex-direction: row-reverse;
5343
- }
5344
- .np-table-content--reversed .np-table-content-body {
5345
- align-items: end;
5346
- }
5347
- .np-table-empty-data {
5348
- display: flex;
5349
- align-items: center;
5350
- }
5351
- .np-table-empty-data .status-circle {
5352
- margin-right: 12px;
5353
- margin-right: var(--size-12);
5354
- }
5355
5055
  .np-tile {
5356
5056
  min-width: 120px;
5357
5057
  border-radius: 10px;
package/src/main.less CHANGED
@@ -61,7 +61,6 @@
61
61
  @import "./summary/Summary.less";
62
62
  @import "./switch/Switch.less";
63
63
  @import "./tabs/Tabs.less";
64
- @import "./table/Table.less";
65
64
  @import "./tile/Tile.less";
66
65
  @import "./tooltip/Tooltip.less";
67
66
  @import "./typeahead/Typeahead.less";
@@ -1,15 +1,16 @@
1
1
  import { Position } from '../common';
2
2
  import { render, fireEvent, screen, mockMatchMedia } from '../test-utils';
3
3
 
4
- import Modal from './Modal';
4
+ import Modal, { ModalProps } from './Modal';
5
5
 
6
6
  mockMatchMedia();
7
7
 
8
8
  describe('Modal', () => {
9
- const props = {
9
+ const props: ModalProps = {
10
10
  onClose: jest.fn(),
11
11
  body: 'Some body',
12
12
  position: Position.TOP,
13
+ open: true,
13
14
  };
14
15
 
15
16
  beforeEach(() => {
@@ -17,14 +18,14 @@ describe('Modal', () => {
17
18
  });
18
19
 
19
20
  it(`doesn't calls onClose when click is inside modal`, () => {
20
- render(<Modal {...props} open />);
21
+ render(<Modal {...props} />);
21
22
 
22
23
  fireEvent.click(getDialog());
23
24
  expect(props.onClose).not.toHaveBeenCalled();
24
25
  });
25
26
 
26
27
  it('calls onClose if click outside the content', () => {
27
- render(<Modal {...props} open />);
28
+ render(<Modal {...props} />);
28
29
  expect(props.onClose).not.toHaveBeenCalled();
29
30
 
30
31
  fireEvent.click(screen.getByRole('presentation'));
@@ -32,7 +33,7 @@ describe('Modal', () => {
32
33
  });
33
34
 
34
35
  it("doesn't call onClose if click outside the content and closing on dimmer is disabled", () => {
35
- render(<Modal {...props} open disableDimmerClickToClose />);
36
+ render(<Modal {...props} disableDimmerClickToClose />);
36
37
 
37
38
  fireEvent.click(screen.getByRole('presentation'));
38
39
 
@@ -40,7 +41,7 @@ describe('Modal', () => {
40
41
  });
41
42
 
42
43
  it('calls onClose when Escape is pressed on Modal', () => {
43
- render(<Modal {...props} open />);
44
+ render(<Modal {...props} />);
44
45
  expect(props.onClose).not.toHaveBeenCalled();
45
46
 
46
47
  fireEvent.keyDown(getDialog(), { key: 'Escape' });
@@ -48,7 +49,7 @@ describe('Modal', () => {
48
49
  });
49
50
 
50
51
  it('calls onClose when Escape is pressed on document', () => {
51
- render(<Modal {...props} open />);
52
+ render(<Modal {...props} />);
52
53
  expect(props.onClose).not.toHaveBeenCalled();
53
54
 
54
55
  fireEvent.keyDown(document, { key: 'Escape' });
@@ -1,6 +1,6 @@
1
1
  import { shallow, mount } from 'enzyme';
2
2
 
3
- import SlidingPanel, { EXIT_ANIMATION } from './SlidingPanel';
3
+ import SlidingPanel from './SlidingPanel';
4
4
 
5
5
  describe('SlidingPanel', () => {
6
6
  let component;
@@ -0,0 +1,264 @@
1
+ /**
2
+ * @jest-environment node
3
+ */
4
+ import { renderToString } from 'react-dom/server';
5
+
6
+ import en from './i18n/en.json';
7
+
8
+ import * as exposedLibraryItems from '.';
9
+
10
+ type ExposedLibraryItemsType = typeof exposedLibraryItems;
11
+ type ExposedLibraryKeysType = keyof ExposedLibraryItemsType;
12
+
13
+ const excluded = new Set<ExposedLibraryKeysType | string>([
14
+ // hooks
15
+ 'useSnackbar',
16
+ 'useDirection',
17
+ 'useLayout',
18
+ 'useScreenSize',
19
+
20
+ // specific components
21
+ 'Provider',
22
+ 'BottomSheet',
23
+ 'DropFade',
24
+ 'SelectInputTriggerButton',
25
+ 'Panel',
26
+ 'ResponsivePanel',
27
+
28
+ // enums
29
+ 'Size',
30
+ 'Width',
31
+ 'Sentiment',
32
+ 'Variant',
33
+ 'Priority',
34
+ 'ControlType',
35
+ 'Type',
36
+ 'Theme',
37
+ 'DateMode',
38
+ 'MonthFormat',
39
+ 'Position',
40
+ 'Scroll',
41
+ 'ProfileType',
42
+ 'Breakpoint',
43
+ 'Layout',
44
+ 'Status',
45
+ 'MarkdownNodeType',
46
+ 'AvatarType',
47
+ 'InfoPresentation',
48
+ 'UploadStep',
49
+ 'DecisionPresentation',
50
+ 'DecisionType',
51
+ 'AlertArrowPosition',
52
+ 'LogoType',
53
+ 'FileType',
54
+ 'Direction',
55
+ 'Typography',
56
+
57
+ // types
58
+ 'SearchInputProps',
59
+ 'SelectInputItem',
60
+ 'SelectInputOptionContentProps',
61
+ 'SelectInputProps',
62
+ 'UploadedFile',
63
+ 'UploadError',
64
+ 'UploadResponse',
65
+ 'LayoutDirection',
66
+
67
+ // utils
68
+ 'SUPPORTED_LANGUAGES',
69
+ 'RTL_LANGUAGES',
70
+ 'DEFAULT_LANG',
71
+ 'DEFAULT_LOCALE',
72
+ 'adjustLocale',
73
+ 'getLangFromLocale',
74
+ 'getCountryFromLocale',
75
+ 'getDirectionFromLocale',
76
+ 'isServerSide',
77
+ 'isBrowser',
78
+
79
+ // other
80
+ 'translations',
81
+ ]);
82
+
83
+ function isNotExcluded(item: ExposedLibraryKeysType) {
84
+ return !excluded.has(item);
85
+ }
86
+
87
+ describe('Server side rendering', () => {
88
+ const componentNames = (
89
+ Object.keys(exposedLibraryItems) as (keyof ExposedLibraryItemsType)[]
90
+ ).filter((moduleName) => isNotExcluded(moduleName));
91
+
92
+ // stick all possible properties we might need to render all components in here
93
+ const allProps: Record<string, unknown> = {
94
+ currencies: [],
95
+ steps: [],
96
+ stepper: {
97
+ steps: [],
98
+ },
99
+ items: [],
100
+ children: 'yo',
101
+ id: '1',
102
+ text: 'test',
103
+ timeout: 0,
104
+ timestamp: 1,
105
+ title: 'trolo',
106
+ name: 'lolo',
107
+ label: 'hello',
108
+ content: 'world',
109
+ currency: 'XYZ',
110
+ amount: 0,
111
+ options: [],
112
+ model: {},
113
+ fields: {},
114
+ media: <h1>Hello</h1>,
115
+ onClick: jest.fn(),
116
+ onChange: jest.fn(),
117
+ status: 'processing',
118
+ size: 'sm',
119
+ body: 'body',
120
+ onClose: jest.fn(),
121
+ onDismiss: jest.fn(),
122
+ onRemove: jest.fn(),
123
+ radios: [
124
+ {
125
+ id: 'id-test-0',
126
+ label: 'Radio1',
127
+ },
128
+ {
129
+ id: 'id-test-0',
130
+ label: 'Radio1',
131
+ },
132
+ ],
133
+ position: 'left',
134
+ open: true,
135
+ tabs: [],
136
+ direction: {
137
+ xs: 'column',
138
+ sm: 'row',
139
+ md: 'column',
140
+ lg: 'row',
141
+ },
142
+ alt: '',
143
+ src: '',
144
+ details: 'yo',
145
+ icon: <svg />,
146
+ badge: <svg />,
147
+ link: 'link',
148
+ href: '#',
149
+ description: 'description',
150
+ 'aria-label': 'a label',
151
+ logo: <svg />,
152
+ chips: [
153
+ {
154
+ value: 1,
155
+ label: 'One',
156
+ },
157
+ {
158
+ value: 2,
159
+ label: 'Two',
160
+ },
161
+ ],
162
+ segments: [
163
+ {
164
+ id: '1',
165
+ value: 'accounting',
166
+ label: 'Accounting',
167
+ },
168
+ {
169
+ id: '2',
170
+ value: 'payroll',
171
+ label: 'Payroll',
172
+ },
173
+ {
174
+ id: '3',
175
+ value: 'reporting',
176
+ label: 'Reporting',
177
+ },
178
+ ],
179
+ };
180
+
181
+ // Override props in case of name collision.
182
+ const overrideProps: Partial<Record<keyof ExposedLibraryItemsType, Record<string, unknown>>> = {
183
+ Alert: { children: undefined, message: 'Fluffy kittens', size: undefined },
184
+ Card: { isExpanded: true },
185
+ CheckboxButton: { children: undefined, onChange: jest.fn() },
186
+ Typeahead: { size: 'md' },
187
+ InputWithDisplayFormat: { displayPattern: '**-**' },
188
+ TextareaWithDisplayFormat: { displayPattern: '**-**' },
189
+ Sticky: { position: 'top' },
190
+ MoneyInput: { selectedCurrency: { currency: 'EUR' } },
191
+ Tabs: { selected: 1, onTabSelect: jest.fn() },
192
+ Markdown: { children: '# Markdown string' },
193
+ SnackbarConsumer: {
194
+ children: jest.fn(),
195
+ },
196
+ SnackbarContext: {
197
+ children: jest.fn(),
198
+ },
199
+ Popover: {
200
+ children: <div />,
201
+ },
202
+ Progress: {
203
+ progress: { value: 50, max: 100 },
204
+ },
205
+ ProgressBar: {
206
+ progress: { value: 50, max: 100 },
207
+ },
208
+ Field: {
209
+ model: 'a model',
210
+ type: 'text',
211
+ children: <input />,
212
+ },
213
+ Input: {
214
+ children: undefined,
215
+ },
216
+ SearchInput: {
217
+ children: undefined,
218
+ },
219
+ TextArea: {
220
+ children: undefined,
221
+ },
222
+ Summary: {
223
+ status: 'done',
224
+ content: undefined,
225
+ },
226
+ Modal: { position: 'top' },
227
+ ActionOption: { action: 'hello' },
228
+ DateLookup: { value: new Date() },
229
+ Link: { size: 16 },
230
+ Tooltip: { children: <>yo</> },
231
+ SelectOption: { placeholder: { media: <img alt="img" /> } },
232
+ };
233
+
234
+ const { Provider } = exposedLibraryItems;
235
+ type ComponentWithProvider = React.ComponentType<unknown> & {
236
+ Provider?: React.ComponentType<unknown>;
237
+ };
238
+
239
+ componentNames.forEach((componentName: ExposedLibraryKeysType) => {
240
+ it(`can render component: ${componentName}`, () => {
241
+ const Component = exposedLibraryItems[componentName] as ComponentWithProvider;
242
+ const newProps = { ...allProps };
243
+
244
+ Object.keys(overrideProps[componentName] ?? {}).forEach((propertyToOverrideKey) => {
245
+ const key = propertyToOverrideKey as keyof (typeof overrideProps)[typeof componentName];
246
+ newProps[key] = overrideProps?.[componentName]?.[key];
247
+ });
248
+
249
+ const view = renderToString(
250
+ <Provider i18n={{ locale: 'en-GB', messages: en }}>
251
+ {componentName.endsWith('Context') && Component.Provider ? (
252
+ <Component.Provider {...newProps} />
253
+ ) : (
254
+ <div>
255
+ <Component {...newProps} />
256
+ </div>
257
+ )}
258
+ </Provider>,
259
+ );
260
+
261
+ expect(view).toStrictEqual(expect.any(String));
262
+ });
263
+ });
264
+ });
@@ -1,8 +1,9 @@
1
+ import { ReactElement, FC } from 'react';
1
2
  import { render, renderHook } from '@testing-library/react';
2
3
  import { userEvent } from '@testing-library/user-event';
3
4
 
4
5
  import { Provider } from '..';
5
- import { DEFAULT_LOCALE } from '../common/locale';
6
+ import { DEFAULT_LOCALE } from '../common';
6
7
  import en from '../i18n/en.json';
7
8
 
8
9
  /**
@@ -10,9 +11,11 @@ import en from '../i18n/en.json';
10
11
  * Source: https://testing-library.com/docs/example-react-intl/#creating-a-custom-render-function
11
12
  *
12
13
  */
13
- function customRender(ui, { locale = DEFAULT_LOCALE, messages = en, ...renderOptions } = {}) {
14
- // eslint-disable-next-line react/prop-types
15
- const Wrapper = ({ children }) => {
14
+ function customRender(
15
+ ui: ReactElement,
16
+ { locale = DEFAULT_LOCALE, messages = en, ...renderOptions } = {},
17
+ ): ReturnType<typeof render> {
18
+ const Wrapper: FC<{ children: React.ReactNode }> = ({ children }) => {
16
19
  return <Provider i18n={{ locale, messages }}>{children}</Provider>;
17
20
  };
18
21
  return render(ui, { wrapper: Wrapper, ...renderOptions });
@@ -21,9 +24,11 @@ function customRender(ui, { locale = DEFAULT_LOCALE, messages = en, ...renderOpt
21
24
  /**
22
25
  * Custom `renderHook` function which wraps passed elements in Provider component
23
26
  * For more info: https://react-hooks-testing-library.com/usage/advanced-hooks#context
24
- *
25
27
  */
26
- function customRenderHook(callback, { locale = DEFAULT_LOCALE, messages = en } = {}) {
28
+ function customRenderHook(
29
+ callback: () => unknown,
30
+ { locale = DEFAULT_LOCALE, messages = en } = {},
31
+ ) {
27
32
  return renderHook(callback, {
28
33
  wrapper: ({ children }) => <Provider i18n={{ locale, messages }}>{children}</Provider>,
29
34
  });