@coveord/plasma-mantine 48.3.0 → 48.7.0

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.
@@ -2,31 +2,32 @@ import {render, screen, userEvent} from '@test-utils';
2
2
  import {ModalWizard} from '../ModalWizard';
3
3
 
4
4
  describe('ModalWizard', () => {
5
- it('navigate slides using footer buttons', async () => {
6
- const user = userEvent.setup({delay: null});
5
+ it('navigate modal steps using footer buttons', async () => {
6
+ const user = userEvent.setup();
7
+
7
8
  const modelSteps = [
8
9
  {
9
10
  docLink: 'https://google.com',
10
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
11
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
11
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
12
+ validateStep: () => ({isValid: true}),
12
13
  element: <div> Slide 1</div>,
13
14
  },
14
15
  {
15
16
  docLink: 'https://google.com',
16
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
17
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
17
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
18
+ validateStep: () => ({isValid: true}),
18
19
  element: <div> Slide 2</div>,
19
20
  },
20
21
  {
21
22
  docLink: 'https://google.com',
22
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
23
- validateStep: (currentStep, numberOfSteps) => ({isValid: false}),
23
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
24
+ validateStep: () => ({isValid: false}),
24
25
  element: <div> Slide 3</div>,
25
26
  },
26
27
  {
27
28
  docLink: 'https://google.com',
28
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
29
- validateStep: (currentStep, numberOfSteps) => ({isValid: false}),
29
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
30
+ validateStep: () => ({isValid: false}),
30
31
  element: <div> Unreachable slide</div>,
31
32
  },
32
33
  ];
@@ -38,11 +39,13 @@ describe('ModalWizard', () => {
38
39
  closeButtonLabel="closebuttonlabel"
39
40
  isDirty={isDirty}
40
41
  handleDirtyState={() => confirm('Are you sure you want to close?')}
42
+ opened={true}
43
+ onClose={undefined}
41
44
  >
42
45
  {modelSteps.map((model_item) => (
43
46
  <ModalWizard.Step
44
47
  docLink={model_item.docLink}
45
- title={(currentStep, numberOfSteps) => 'Current Step is: ' + currentStep}
48
+ title={(currentStep) => 'Current Step is: ' + currentStep}
46
49
  validateStep={model_item.validateStep}
47
50
  >
48
51
  {model_item.element}
@@ -153,13 +156,14 @@ describe('ModalWizard', () => {
153
156
  ).toBeInTheDocument();
154
157
  });
155
158
 
156
- it('modal wizard onClose', async () => {
157
- const user = userEvent.setup({delay: null});
159
+ it('calls the onClose prop when closing the modal', async () => {
160
+ const user = userEvent.setup();
161
+
158
162
  const modelSteps = [
159
163
  {
160
164
  docLink: 'https://google.com',
161
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
162
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
165
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
166
+ validateStep: () => ({isValid: true}),
163
167
  element: <div> Slide 1</div>,
164
168
  },
165
169
  ];
@@ -168,11 +172,11 @@ describe('ModalWizard', () => {
168
172
  const onClose = jest.fn();
169
173
 
170
174
  render(
171
- <ModalWizard isDirty={isDirty} onClose={onClose} closeButtonLabel="closebuttonlabel">
175
+ <ModalWizard isDirty={isDirty} onClose={onClose} closeButtonLabel="closebuttonlabel" opened={true}>
172
176
  {modelSteps.map((model_item) => (
173
177
  <ModalWizard.Step
174
178
  docLink={model_item.docLink}
175
- title={(currentStep, numberOfSteps) => 'Current Step is: ' + currentStep}
179
+ title={(currentStep) => 'Current Step is: ' + currentStep}
176
180
  validateStep={model_item.validateStep}
177
181
  >
178
182
  {model_item.element}
@@ -189,13 +193,13 @@ describe('ModalWizard', () => {
189
193
  expect(onClose).toHaveBeenCalledTimes(1);
190
194
  });
191
195
 
192
- it('modal wizard onCancel', async () => {
193
- const user = userEvent.setup({delay: null});
196
+ it('closes the modal when clicking on cancel', async () => {
197
+ const user = userEvent.setup();
194
198
  const modelSteps = [
195
199
  {
196
200
  docLink: 'https://google.com',
197
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
198
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
201
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
202
+ validateStep: () => ({isValid: true}),
199
203
  element: <div> Slide 1</div>,
200
204
  },
201
205
  ];
@@ -204,11 +208,11 @@ describe('ModalWizard', () => {
204
208
  const onClose = jest.fn();
205
209
 
206
210
  render(
207
- <ModalWizard isDirty={isDirty} onClose={onClose}>
211
+ <ModalWizard isDirty={isDirty} onClose={onClose} opened={true}>
208
212
  {modelSteps.map((model_item) => (
209
213
  <ModalWizard.Step
210
214
  docLink={model_item.docLink}
211
- title={(currentStep, numberOfSteps) => 'Current Step is: ' + currentStep}
215
+ title={(currentStep) => 'Current Step is: ' + currentStep}
212
216
  validateStep={model_item.validateStep}
213
217
  >
214
218
  {model_item.element}
@@ -225,13 +229,13 @@ describe('ModalWizard', () => {
225
229
  expect(onClose).toHaveBeenCalledTimes(1);
226
230
  });
227
231
 
228
- it('modal wizard onFinish', async () => {
229
- const user = userEvent.setup({delay: null});
232
+ it('calls onFinish prop when clicking on finish button', async () => {
233
+ const user = userEvent.setup();
230
234
  const modelSteps = [
231
235
  {
232
236
  docLink: 'https://google.com',
233
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
234
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
237
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
238
+ validateStep: () => ({isValid: true}),
235
239
  element: <div> Slide 1</div>,
236
240
  },
237
241
  ];
@@ -241,11 +245,11 @@ describe('ModalWizard', () => {
241
245
  const onFinish = jest.fn();
242
246
 
243
247
  render(
244
- <ModalWizard isDirty={isDirty} onClose={onClose} onFinish={onFinish}>
248
+ <ModalWizard isDirty={isDirty} onClose={onClose} onFinish={onFinish} opened={true}>
245
249
  {modelSteps.map((model_item) => (
246
250
  <ModalWizard.Step
247
251
  docLink={model_item.docLink}
248
- title={(currentStep, numberOfSteps) => 'Current Step is: ' + currentStep}
252
+ title={(currentStep) => 'Current Step is: ' + currentStep}
249
253
  validateStep={model_item.validateStep}
250
254
  >
251
255
  {model_item.element}
@@ -262,13 +266,13 @@ describe('ModalWizard', () => {
262
266
  expect(onFinish).toHaveBeenCalledTimes(1);
263
267
  });
264
268
 
265
- it('handle dirty state if user confirms close', async () => {
266
- const user = userEvent.setup({delay: null});
269
+ it('triggers handleDirty callback when the modal wizard has dirty state', async () => {
270
+ const user = userEvent.setup();
267
271
  const modelSteps = [
268
272
  {
269
273
  docLink: 'https://google.com',
270
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
271
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
274
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
275
+ validateStep: () => ({isValid: true}),
272
276
  element: <div> Slide 1</div>,
273
277
  },
274
278
  ];
@@ -283,11 +287,12 @@ describe('ModalWizard', () => {
283
287
  onClose={onClose}
284
288
  handleDirtyState={handleDirtyState}
285
289
  closeButtonLabel="closebuttonlabel"
290
+ opened={true}
286
291
  >
287
292
  {modelSteps.map((model_item) => (
288
293
  <ModalWizard.Step
289
294
  docLink={model_item.docLink}
290
- title={(currentStep, numberOfSteps) => 'Current Step is: ' + currentStep}
295
+ title={(currentStep) => 'Current Step is: ' + currentStep}
291
296
  validateStep={model_item.validateStep}
292
297
  >
293
298
  {model_item.element}
@@ -306,13 +311,13 @@ describe('ModalWizard', () => {
306
311
  expect(onClose).toHaveBeenCalledTimes(1);
307
312
  });
308
313
 
309
- it('handle dirty state if user confirms cancel', async () => {
310
- const user = userEvent.setup({delay: null});
314
+ it('close the modal if user confirms close when the modal wizard has dirty state', async () => {
315
+ const user = userEvent.setup();
311
316
  const modelSteps = [
312
317
  {
313
318
  docLink: 'https://google.com',
314
- title: (currentStep, numberOfSteps) => 'Current Step is: ' + currentStep,
315
- validateStep: (currentStep, numberOfSteps) => ({isValid: true}),
319
+ title: (currentStep: string) => 'Current Step is: ' + currentStep,
320
+ validateStep: () => ({isValid: true}),
316
321
  element: <div> Slide 1</div>,
317
322
  },
318
323
  ];
@@ -327,11 +332,12 @@ describe('ModalWizard', () => {
327
332
  onClose={onClose}
328
333
  handleDirtyState={handleDirtyState}
329
334
  closeButtonLabel="closebuttonlabel"
335
+ opened={true}
330
336
  >
331
337
  {modelSteps.map((model_item) => (
332
338
  <ModalWizard.Step
333
339
  docLink={model_item.docLink}
334
- title={(currentStep, numberOfSteps) => 'Current Step is: ' + currentStep}
340
+ title={(currentStep) => 'Current Step is: ' + currentStep}
335
341
  validateStep={model_item.validateStep}
336
342
  >
337
343
  {model_item.element}