@terreno/ui 0.31.0 → 56.0.0-beta.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/dist/ActionSheet.d.ts +1 -1
- package/dist/Avatar.js +1 -4
- package/dist/Avatar.js.map +1 -1
- package/dist/Box.js +45 -9
- package/dist/Box.js.map +1 -1
- package/dist/Common.d.ts +21 -0
- package/dist/Common.js.map +1 -1
- package/dist/ConflictSheet.d.ts +53 -0
- package/dist/ConflictSheet.js +132 -0
- package/dist/ConflictSheet.js.map +1 -0
- package/dist/DateTimeActionSheet.d.ts +2 -1
- package/dist/DateTimeField.js +5 -21
- package/dist/DateTimeField.js.map +1 -1
- package/dist/DecimalRangeActionSheet.d.ts +1 -1
- package/dist/EmojiSelector.d.ts +1 -1
- package/dist/ErrorPage.d.ts +1 -1
- package/dist/HeightActionSheet.d.ts +1 -1
- package/dist/Hyperlink.d.ts +2 -1
- package/dist/Hyperlink.js +2 -1
- package/dist/Hyperlink.js.map +1 -1
- package/dist/Image.d.ts +1 -1
- package/dist/ImageBackground.d.ts +1 -1
- package/dist/MobileAddressAutoComplete.d.ts +1 -1
- package/dist/NumberPickerActionSheet.d.ts +1 -1
- package/dist/Page.d.ts +5 -4
- package/dist/Page.js +0 -2
- package/dist/Page.js.map +1 -1
- package/dist/PickerSelect.d.ts +1 -1
- package/dist/SidebarNavigation.js +1 -1
- package/dist/SidebarNavigation.js.map +1 -1
- package/dist/SidebarNavigation.native.js +1 -1
- package/dist/SidebarNavigation.native.js.map +1 -1
- package/dist/SplitPage.d.ts +1 -1
- package/dist/SplitPage.js +1 -4
- package/dist/SplitPage.js.map +1 -1
- package/dist/SplitPage.native.d.ts +1 -1
- package/dist/SyncStatusBanner.d.ts +46 -0
- package/dist/SyncStatusBanner.js +29 -0
- package/dist/SyncStatusBanner.js.map +1 -0
- package/dist/Theme.d.ts +1 -1
- package/dist/Toast.d.ts +9 -1
- package/dist/Toast.js +20 -7
- package/dist/Toast.js.map +1 -1
- package/dist/ToastNotifications.js +23 -1
- package/dist/ToastNotifications.js.map +1 -1
- package/dist/UnifiedAddressAutoComplete.d.ts +1 -1
- package/dist/Unifier.js +1 -1
- package/dist/Unifier.js.map +1 -1
- package/dist/conflictFieldDiff.d.ts +14 -0
- package/dist/conflictFieldDiff.js +62 -0
- package/dist/conflictFieldDiff.js.map +1 -0
- package/dist/icons/OfflineIcon.d.ts +1 -1
- package/dist/icons/OnlineIcon.d.ts +1 -1
- package/dist/icons/OutOfficeIcon.d.ts +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/pdfHtmlTemplate.d.ts +30 -0
- package/dist/pdfHtmlTemplate.js +170 -0
- package/dist/pdfHtmlTemplate.js.map +1 -0
- package/dist/table/TableTitle.js +1 -3
- package/dist/table/TableTitle.js.map +1 -1
- package/dist/useAppLaunchOrForeground.d.ts +9 -0
- package/dist/useAppLaunchOrForeground.js +27 -0
- package/dist/useAppLaunchOrForeground.js.map +1 -0
- package/package.json +44 -37
- package/src/ActionSheet.test.tsx +123 -136
- package/src/Box.test.tsx +68 -30
- package/src/Box.tsx +46 -7
- package/src/Common.ts +21 -3
- package/src/ConflictSheet.test.tsx +461 -0
- package/src/ConflictSheet.tsx +399 -0
- package/src/ConsentFormScreen.test.tsx +22 -0
- package/src/DateTimeField.test.tsx +14 -0
- package/src/DateTimeField.tsx +5 -19
- package/src/Hyperlink.tsx +1 -1
- package/src/Page.tsx +2 -3
- package/src/SidebarNavigation.native.tsx +1 -1
- package/src/SidebarNavigation.tsx +1 -1
- package/src/SyncStatusBanner.test.tsx +204 -0
- package/src/SyncStatusBanner.tsx +148 -0
- package/src/TerrenoProvider.test.tsx +3 -4
- package/src/Toast.test.tsx +60 -0
- package/src/Toast.tsx +46 -1
- package/src/ToastNotifications.test.tsx +82 -0
- package/src/ToastNotifications.tsx +25 -1
- package/src/Unifier.ts +1 -1
- package/src/WebDropdownMenu.test.tsx +128 -0
- package/src/__snapshots__/AiSuggestionBox.test.tsx.snap +0 -3
- package/src/__snapshots__/Body.test.tsx.snap +0 -16
- package/src/__snapshots__/Box.test.tsx.snap +4 -13
- package/src/__snapshots__/Page.test.tsx.snap +0 -84
- package/src/__snapshots__/SplitPage.test.tsx.snap +24 -120
- package/src/__snapshots__/TapToEdit.test.tsx.snap +5 -16
- package/src/__snapshots__/Toast.test.tsx.snap +4 -2
- package/src/bunSetup.ts +19 -0
- package/src/conflictFieldDiff.test.ts +26 -0
- package/src/conflictFieldDiff.ts +78 -0
- package/src/index.tsx +5 -2
- package/src/login/__snapshots__/LoginScreen.test.tsx.snap +0 -9
- package/src/pdfHtmlTemplate.ts +219 -0
- package/src/signUp/__snapshots__/OAuthButtons.test.tsx.snap +0 -1
- package/src/signUp/__snapshots__/PasswordRequirements.test.tsx.snap +2 -16
- package/src/signUp/__snapshots__/SignUpScreen.test.tsx.snap +1 -17
- package/src/signUp/__snapshots__/Swiper.test.tsx.snap +0 -1
- package/src/table/__snapshots__/Table.test.tsx.snap +22 -87
- package/src/table/__snapshots__/TableHeader.test.tsx.snap +10 -50
- package/src/table/__snapshots__/TableHeaderCell.test.tsx.snap +10 -84
- package/src/table/__snapshots__/TableRow.test.tsx.snap +12 -77
- package/src/useAppLaunchOrForeground.test.tsx +54 -0
- package/src/useAppLaunchOrForeground.ts +30 -0
- package/dist/ConsentHistory.d.ts +0 -9
- package/dist/ConsentHistory.js +0 -70
- package/dist/ConsentHistory.js.map +0 -1
- package/dist/generateConsentHistoryPdf.d.ts +0 -2
- package/dist/generateConsentHistoryPdf.js +0 -185
- package/dist/generateConsentHistoryPdf.js.map +0 -1
- package/dist/useConsentHistory.d.ts +0 -63
- package/dist/useConsentHistory.js +0 -40
- package/dist/useConsentHistory.js.map +0 -1
- package/src/ConsentHistory.test.tsx +0 -224
- package/src/ConsentHistory.tsx +0 -249
- package/src/generateConsentHistoryPdf.test.ts +0 -253
- package/src/generateConsentHistoryPdf.ts +0 -211
- package/src/useConsentHistory.test.ts +0 -106
- package/src/useConsentHistory.ts +0 -94
package/src/ActionSheet.test.tsx
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
// noExplicitAny: test mock typing
|
|
2
|
-
// biome-ignore-all lint/suspicious/noExplicitAny: test mock typing
|
|
3
1
|
import {afterAll, afterEach, beforeAll, describe, expect, it, type Mock, mock} from "bun:test";
|
|
4
2
|
import {act, render} from "@testing-library/react-native";
|
|
5
3
|
import {createRef, type RefObject} from "react";
|
|
6
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Animated,
|
|
6
|
+
Dimensions,
|
|
7
|
+
type KeyboardEvent,
|
|
8
|
+
type LayoutChangeEvent,
|
|
9
|
+
type NativeScrollEvent,
|
|
10
|
+
type NativeSyntheticEvent,
|
|
11
|
+
Text,
|
|
12
|
+
} from "react-native";
|
|
7
13
|
|
|
8
14
|
import {
|
|
9
15
|
ActionSheet,
|
|
@@ -14,11 +20,32 @@ import {
|
|
|
14
20
|
} from "./ActionSheet";
|
|
15
21
|
import {ThemeProvider} from "./Theme";
|
|
16
22
|
|
|
23
|
+
const scrollEvent = (y: number): NativeSyntheticEvent<NativeScrollEvent> =>
|
|
24
|
+
({nativeEvent: {contentOffset: {x: 0, y}}}) as NativeSyntheticEvent<NativeScrollEvent>;
|
|
25
|
+
|
|
26
|
+
const layoutEvent = (height: number, width: number): LayoutChangeEvent =>
|
|
27
|
+
({nativeEvent: {layout: {height, width, x: 0, y: 0}}}) as LayoutChangeEvent;
|
|
28
|
+
|
|
29
|
+
/** Stands in for the SafeAreaView ref, whose measureInWindow reports `height`. */
|
|
30
|
+
const measuringSafeAreaRef = (
|
|
31
|
+
height: number
|
|
32
|
+
): React.RefObject<{
|
|
33
|
+
measureInWindow: (
|
|
34
|
+
callback: (x: number, y: number, width: number, height: number) => void
|
|
35
|
+
) => void;
|
|
36
|
+
}> => ({
|
|
37
|
+
current: {
|
|
38
|
+
measureInWindow: (callback) => {
|
|
39
|
+
callback(0, 0, 100, height);
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
17
44
|
beforeAll(() => {
|
|
18
|
-
|
|
45
|
+
globalThis.requestAnimationFrame = (callback: FrameRequestCallback) => {
|
|
19
46
|
return setTimeout(() => callback(Date.now()), 0) as unknown as number;
|
|
20
47
|
};
|
|
21
|
-
|
|
48
|
+
globalThis.cancelAnimationFrame = (id: number) => {
|
|
22
49
|
clearTimeout(id);
|
|
23
50
|
};
|
|
24
51
|
});
|
|
@@ -232,7 +259,7 @@ describe("ActionSheet", () => {
|
|
|
232
259
|
act(() => {
|
|
233
260
|
ref.current?.show();
|
|
234
261
|
});
|
|
235
|
-
expect(() =>
|
|
262
|
+
expect(() => ref.current!._onRequestClose()).not.toThrow();
|
|
236
263
|
});
|
|
237
264
|
|
|
238
265
|
it("_onTouchBackdrop hides modal when closeOnTouchBackdrop is true", () => {
|
|
@@ -247,7 +274,7 @@ describe("ActionSheet", () => {
|
|
|
247
274
|
act(() => {
|
|
248
275
|
ref.current?.show();
|
|
249
276
|
});
|
|
250
|
-
expect(() =>
|
|
277
|
+
expect(() => ref.current!._onTouchBackdrop()).not.toThrow();
|
|
251
278
|
});
|
|
252
279
|
|
|
253
280
|
it("_onRequestClose does not hide when closeOnPressBack is false", () => {
|
|
@@ -262,7 +289,7 @@ describe("ActionSheet", () => {
|
|
|
262
289
|
act(() => {
|
|
263
290
|
ref.current?.show();
|
|
264
291
|
});
|
|
265
|
-
|
|
292
|
+
ref.current!._onRequestClose();
|
|
266
293
|
expect(ref.current?.state.modalVisible).toBe(true);
|
|
267
294
|
});
|
|
268
295
|
|
|
@@ -278,7 +305,7 @@ describe("ActionSheet", () => {
|
|
|
278
305
|
act(() => {
|
|
279
306
|
ref.current?.show();
|
|
280
307
|
});
|
|
281
|
-
|
|
308
|
+
ref.current!._onTouchBackdrop();
|
|
282
309
|
expect(ref.current?.state.modalVisible).toBe(true);
|
|
283
310
|
});
|
|
284
311
|
|
|
@@ -291,11 +318,7 @@ describe("ActionSheet", () => {
|
|
|
291
318
|
</ActionSheet>
|
|
292
319
|
</ThemeProvider>
|
|
293
320
|
);
|
|
294
|
-
expect(() =>
|
|
295
|
-
(ref.current as any)._onScroll({
|
|
296
|
-
nativeEvent: {contentOffset: {x: 0, y: 10}},
|
|
297
|
-
})
|
|
298
|
-
).not.toThrow();
|
|
321
|
+
expect(() => ref.current!._onScroll(scrollEvent(10))).not.toThrow();
|
|
299
322
|
});
|
|
300
323
|
|
|
301
324
|
it("_onTouchStart and _onTouchMove do not throw", () => {
|
|
@@ -307,9 +330,9 @@ describe("ActionSheet", () => {
|
|
|
307
330
|
</ActionSheet>
|
|
308
331
|
</ThemeProvider>
|
|
309
332
|
);
|
|
310
|
-
expect(() =>
|
|
311
|
-
expect(() =>
|
|
312
|
-
expect(() =>
|
|
333
|
+
expect(() => ref.current!._onTouchStart()).not.toThrow();
|
|
334
|
+
expect(() => ref.current!._onTouchMove()).not.toThrow();
|
|
335
|
+
expect(() => ref.current!._onTouchEnd()).not.toThrow();
|
|
313
336
|
});
|
|
314
337
|
|
|
315
338
|
describe("getDeviceHeight", () => {
|
|
@@ -356,7 +379,7 @@ describe("ActionSheet", () => {
|
|
|
356
379
|
</ActionSheet>
|
|
357
380
|
</ThemeProvider>
|
|
358
381
|
);
|
|
359
|
-
const result = await
|
|
382
|
+
const result = await ref.current!.measure();
|
|
360
383
|
expect(result).toBe(20);
|
|
361
384
|
});
|
|
362
385
|
|
|
@@ -369,14 +392,8 @@ describe("ActionSheet", () => {
|
|
|
369
392
|
</ActionSheet>
|
|
370
393
|
</ThemeProvider>
|
|
371
394
|
);
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
measureInWindow: (_cb: any) => {
|
|
375
|
-
_cb(0, 0, 100, 44);
|
|
376
|
-
},
|
|
377
|
-
},
|
|
378
|
-
};
|
|
379
|
-
const result = await (ref.current as any).measure();
|
|
395
|
+
ref.current!.safeAreaViewRef = measuringSafeAreaRef(44);
|
|
396
|
+
const result = await ref.current!.measure();
|
|
380
397
|
expect(result).toBe(44);
|
|
381
398
|
});
|
|
382
399
|
|
|
@@ -389,14 +406,8 @@ describe("ActionSheet", () => {
|
|
|
389
406
|
</ActionSheet>
|
|
390
407
|
</ThemeProvider>
|
|
391
408
|
);
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
measureInWindow: (_cb: any) => {
|
|
395
|
-
_cb(0, 0, 100, 0);
|
|
396
|
-
},
|
|
397
|
-
},
|
|
398
|
-
};
|
|
399
|
-
const result = await (ref.current as any).measure();
|
|
409
|
+
ref.current!.safeAreaViewRef = measuringSafeAreaRef(0);
|
|
410
|
+
const result = await ref.current!.measure();
|
|
400
411
|
expect(result).toBe(20);
|
|
401
412
|
});
|
|
402
413
|
});
|
|
@@ -411,7 +422,7 @@ describe("ActionSheet", () => {
|
|
|
411
422
|
</ActionSheet>
|
|
412
423
|
</ThemeProvider>
|
|
413
424
|
);
|
|
414
|
-
await
|
|
425
|
+
await ref.current!._showModal({} as LayoutChangeEvent);
|
|
415
426
|
expect(ref.current).toBeTruthy();
|
|
416
427
|
});
|
|
417
428
|
|
|
@@ -425,10 +436,8 @@ describe("ActionSheet", () => {
|
|
|
425
436
|
</ThemeProvider>
|
|
426
437
|
);
|
|
427
438
|
ref.current!.layoutHasCalled = false;
|
|
428
|
-
await
|
|
429
|
-
|
|
430
|
-
});
|
|
431
|
-
expect((ref.current as any).actionSheetHeight).toBe(500);
|
|
439
|
+
await ref.current!._showModal(layoutEvent(500, 400));
|
|
440
|
+
expect(ref.current!.actionSheetHeight).toBe(500);
|
|
432
441
|
expect(ref.current!.layoutHasCalled).toBe(true);
|
|
433
442
|
});
|
|
434
443
|
|
|
@@ -442,11 +451,9 @@ describe("ActionSheet", () => {
|
|
|
442
451
|
</ThemeProvider>
|
|
443
452
|
);
|
|
444
453
|
ref.current!.layoutHasCalled = true;
|
|
445
|
-
|
|
446
|
-
await
|
|
447
|
-
|
|
448
|
-
});
|
|
449
|
-
expect((ref.current as any).actionSheetHeight).toBe(600);
|
|
454
|
+
ref.current!.actionSheetHeight = 400;
|
|
455
|
+
await ref.current!._showModal(layoutEvent(600, 400));
|
|
456
|
+
expect(ref.current!.actionSheetHeight).toBe(600);
|
|
450
457
|
});
|
|
451
458
|
});
|
|
452
459
|
|
|
@@ -460,7 +467,7 @@ describe("ActionSheet", () => {
|
|
|
460
467
|
</ActionSheet>
|
|
461
468
|
</ThemeProvider>
|
|
462
469
|
);
|
|
463
|
-
expect(() =>
|
|
470
|
+
expect(() => ref.current!._openAnimation(100)).not.toThrow();
|
|
464
471
|
});
|
|
465
472
|
|
|
466
473
|
it("sets opacity directly when animated is false", () => {
|
|
@@ -472,7 +479,7 @@ describe("ActionSheet", () => {
|
|
|
472
479
|
</ActionSheet>
|
|
473
480
|
</ThemeProvider>
|
|
474
481
|
);
|
|
475
|
-
expect(() =>
|
|
482
|
+
expect(() => ref.current!._openAnimation(100)).not.toThrow();
|
|
476
483
|
});
|
|
477
484
|
});
|
|
478
485
|
|
|
@@ -486,10 +493,8 @@ describe("ActionSheet", () => {
|
|
|
486
493
|
</ActionSheet>
|
|
487
494
|
</ThemeProvider>
|
|
488
495
|
);
|
|
489
|
-
await
|
|
490
|
-
|
|
491
|
-
});
|
|
492
|
-
expect((ref.current as any).prevScroll).toBe(42);
|
|
496
|
+
await ref.current!._onScrollBeginDrag(scrollEvent(42));
|
|
497
|
+
expect(ref.current!.prevScroll).toBe(42);
|
|
493
498
|
});
|
|
494
499
|
});
|
|
495
500
|
|
|
@@ -503,11 +508,9 @@ describe("ActionSheet", () => {
|
|
|
503
508
|
</ActionSheet>
|
|
504
509
|
</ThemeProvider>
|
|
505
510
|
);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
expect(
|
|
509
|
-
ref.current!.state.deviceHeight
|
|
510
|
-
);
|
|
511
|
+
ref.current!.actionSheetHeight = 99999;
|
|
512
|
+
ref.current!._applyHeightLimiter();
|
|
513
|
+
expect(ref.current!.actionSheetHeight).toBeLessThanOrEqual(ref.current!.state.deviceHeight);
|
|
511
514
|
});
|
|
512
515
|
|
|
513
516
|
it("does not change actionSheetHeight when smaller than deviceHeight", () => {
|
|
@@ -519,9 +522,9 @@ describe("ActionSheet", () => {
|
|
|
519
522
|
</ActionSheet>
|
|
520
523
|
</ThemeProvider>
|
|
521
524
|
);
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
expect(
|
|
525
|
+
ref.current!.actionSheetHeight = 100;
|
|
526
|
+
ref.current!._applyHeightLimiter();
|
|
527
|
+
expect(ref.current!.actionSheetHeight).toBe(100);
|
|
525
528
|
});
|
|
526
529
|
});
|
|
527
530
|
|
|
@@ -535,12 +538,10 @@ describe("ActionSheet", () => {
|
|
|
535
538
|
</ActionSheet>
|
|
536
539
|
</ThemeProvider>
|
|
537
540
|
);
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
await
|
|
542
|
-
nativeEvent: {contentOffset: {y: 200}},
|
|
543
|
-
});
|
|
541
|
+
ref.current!.prevScroll = 100;
|
|
542
|
+
ref.current!.actionSheetHeight = 500;
|
|
543
|
+
ref.current!.isRecoiling = false;
|
|
544
|
+
await ref.current!._onScrollEnd(scrollEvent(200));
|
|
544
545
|
expect(ref.current).toBeTruthy();
|
|
545
546
|
});
|
|
546
547
|
|
|
@@ -553,10 +554,8 @@ describe("ActionSheet", () => {
|
|
|
553
554
|
</ActionSheet>
|
|
554
555
|
</ThemeProvider>
|
|
555
556
|
);
|
|
556
|
-
|
|
557
|
-
await
|
|
558
|
-
nativeEvent: {contentOffset: {y: 50}},
|
|
559
|
-
});
|
|
557
|
+
ref.current!.isRecoiling = true;
|
|
558
|
+
await ref.current!._onScrollEnd(scrollEvent(50));
|
|
560
559
|
expect(ref.current).toBeTruthy();
|
|
561
560
|
});
|
|
562
561
|
|
|
@@ -569,11 +568,9 @@ describe("ActionSheet", () => {
|
|
|
569
568
|
</ActionSheet>
|
|
570
569
|
</ThemeProvider>
|
|
571
570
|
);
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
await
|
|
575
|
-
nativeEvent: {contentOffset: {y: 50}},
|
|
576
|
-
});
|
|
571
|
+
ref.current!.prevScroll = 200;
|
|
572
|
+
ref.current!.isRecoiling = false;
|
|
573
|
+
await ref.current!._onScrollEnd(scrollEvent(50));
|
|
577
574
|
expect(ref.current).toBeTruthy();
|
|
578
575
|
});
|
|
579
576
|
|
|
@@ -586,11 +583,9 @@ describe("ActionSheet", () => {
|
|
|
586
583
|
</ActionSheet>
|
|
587
584
|
</ThemeProvider>
|
|
588
585
|
);
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
await
|
|
592
|
-
nativeEvent: {contentOffset: {y: 95}},
|
|
593
|
-
});
|
|
586
|
+
ref.current!.prevScroll = 100;
|
|
587
|
+
ref.current!.isRecoiling = false;
|
|
588
|
+
await ref.current!._onScrollEnd(scrollEvent(95));
|
|
594
589
|
expect(ref.current).toBeTruthy();
|
|
595
590
|
});
|
|
596
591
|
|
|
@@ -603,12 +598,10 @@ describe("ActionSheet", () => {
|
|
|
603
598
|
</ActionSheet>
|
|
604
599
|
</ThemeProvider>
|
|
605
600
|
);
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
await
|
|
610
|
-
nativeEvent: {contentOffset: {y: 110}},
|
|
611
|
-
});
|
|
601
|
+
ref.current!.prevScroll = 100;
|
|
602
|
+
ref.current!.actionSheetHeight = 500;
|
|
603
|
+
ref.current!.isRecoiling = false;
|
|
604
|
+
await ref.current!._onScrollEnd(scrollEvent(110));
|
|
612
605
|
expect(ref.current).toBeTruthy();
|
|
613
606
|
});
|
|
614
607
|
});
|
|
@@ -748,7 +741,7 @@ describe("ActionSheet", () => {
|
|
|
748
741
|
</ThemeProvider>
|
|
749
742
|
);
|
|
750
743
|
act(() => {
|
|
751
|
-
|
|
744
|
+
ref.current!._onKeyboardHide();
|
|
752
745
|
});
|
|
753
746
|
expect(ref.current!.state.keyboard).toBe(false);
|
|
754
747
|
});
|
|
@@ -764,9 +757,9 @@ describe("ActionSheet", () => {
|
|
|
764
757
|
</ActionSheet>
|
|
765
758
|
</ThemeProvider>
|
|
766
759
|
);
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
await
|
|
760
|
+
ref.current!.offsetY = 200;
|
|
761
|
+
ref.current!.prevScroll = 100;
|
|
762
|
+
await ref.current!.handleChildScrollEnd();
|
|
770
763
|
expect(ref.current).toBeTruthy();
|
|
771
764
|
});
|
|
772
765
|
|
|
@@ -779,10 +772,10 @@ describe("ActionSheet", () => {
|
|
|
779
772
|
</ActionSheet>
|
|
780
773
|
</ThemeProvider>
|
|
781
774
|
);
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
await
|
|
775
|
+
ref.current!.offsetY = 0;
|
|
776
|
+
ref.current!.prevScroll = 200;
|
|
777
|
+
ref.current!.actionSheetHeight = 500;
|
|
778
|
+
await ref.current!.handleChildScrollEnd();
|
|
786
779
|
expect(ref.current).toBeTruthy();
|
|
787
780
|
});
|
|
788
781
|
|
|
@@ -795,9 +788,9 @@ describe("ActionSheet", () => {
|
|
|
795
788
|
</ActionSheet>
|
|
796
789
|
</ThemeProvider>
|
|
797
790
|
);
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
await
|
|
791
|
+
ref.current!.offsetY = 90;
|
|
792
|
+
ref.current!.prevScroll = 100;
|
|
793
|
+
await ref.current!.handleChildScrollEnd();
|
|
801
794
|
expect(ref.current).toBeTruthy();
|
|
802
795
|
});
|
|
803
796
|
|
|
@@ -810,10 +803,10 @@ describe("ActionSheet", () => {
|
|
|
810
803
|
</ActionSheet>
|
|
811
804
|
</ThemeProvider>
|
|
812
805
|
);
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
await
|
|
806
|
+
ref.current!.offsetY = 50;
|
|
807
|
+
ref.current!.prevScroll = 200;
|
|
808
|
+
ref.current!.actionSheetHeight = 200;
|
|
809
|
+
await ref.current!.handleChildScrollEnd();
|
|
817
810
|
expect(ref.current).toBeTruthy();
|
|
818
811
|
});
|
|
819
812
|
});
|
|
@@ -843,11 +836,9 @@ describe("ActionSheet", () => {
|
|
|
843
836
|
</ThemeProvider>
|
|
844
837
|
);
|
|
845
838
|
const existingTimeout = setTimeout(() => {}, 1000);
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
});
|
|
850
|
-
const newTimeout = (ref.current as any).timeout;
|
|
839
|
+
ref.current!.timeout = existingTimeout;
|
|
840
|
+
ref.current!._onDeviceLayout(layoutEvent(812, 375));
|
|
841
|
+
const newTimeout = ref.current!.timeout;
|
|
851
842
|
expect(newTimeout).not.toBe(existingTimeout);
|
|
852
843
|
clearTimeout(newTimeout);
|
|
853
844
|
});
|
|
@@ -863,8 +854,8 @@ describe("ActionSheet", () => {
|
|
|
863
854
|
</ActionSheet>
|
|
864
855
|
</ThemeProvider>
|
|
865
856
|
);
|
|
866
|
-
|
|
867
|
-
const pos =
|
|
857
|
+
ref.current!.actionSheetHeight = 500;
|
|
858
|
+
const pos = ref.current!.getInitialScrollPosition();
|
|
868
859
|
expect(typeof pos).toBe("number");
|
|
869
860
|
});
|
|
870
861
|
|
|
@@ -877,8 +868,8 @@ describe("ActionSheet", () => {
|
|
|
877
868
|
</ActionSheet>
|
|
878
869
|
</ThemeProvider>
|
|
879
870
|
);
|
|
880
|
-
|
|
881
|
-
const pos =
|
|
871
|
+
ref.current!.actionSheetHeight = 500;
|
|
872
|
+
const pos = ref.current!.getInitialScrollPosition();
|
|
882
873
|
expect(typeof pos).toBe("number");
|
|
883
874
|
});
|
|
884
875
|
});
|
|
@@ -896,9 +887,9 @@ describe("ActionSheet", () => {
|
|
|
896
887
|
act(() => {
|
|
897
888
|
ref.current?.show();
|
|
898
889
|
});
|
|
899
|
-
|
|
890
|
+
ref.current!.isClosing = false;
|
|
900
891
|
act(() => {
|
|
901
|
-
|
|
892
|
+
ref.current!._hideAnimation();
|
|
902
893
|
});
|
|
903
894
|
await act(async () => {
|
|
904
895
|
await new Promise((r) => setTimeout(r, 50));
|
|
@@ -918,9 +909,9 @@ describe("ActionSheet", () => {
|
|
|
918
909
|
act(() => {
|
|
919
910
|
ref.current?.show();
|
|
920
911
|
});
|
|
921
|
-
|
|
912
|
+
ref.current!.isClosing = false;
|
|
922
913
|
act(() => {
|
|
923
|
-
|
|
914
|
+
ref.current!._hideAnimation();
|
|
924
915
|
});
|
|
925
916
|
await act(async () => {
|
|
926
917
|
await new Promise((r) => setTimeout(r, 50));
|
|
@@ -939,7 +930,7 @@ describe("ActionSheet", () => {
|
|
|
939
930
|
</ActionSheet>
|
|
940
931
|
</ThemeProvider>
|
|
941
932
|
);
|
|
942
|
-
await expect(
|
|
933
|
+
await expect(ref.current!._onScrollBegin()).resolves.toBeUndefined();
|
|
943
934
|
});
|
|
944
935
|
});
|
|
945
936
|
|
|
@@ -953,19 +944,19 @@ describe("ActionSheet", () => {
|
|
|
953
944
|
</ActionSheet>
|
|
954
945
|
</ThemeProvider>
|
|
955
946
|
);
|
|
956
|
-
|
|
947
|
+
ref.current!.actionSheetHeight = 100;
|
|
957
948
|
// scrollOffset ≈ 100*0.5 + deviceHeight*0.15 ≈ 150
|
|
958
949
|
// Need offsetY > scrollOffset - 100, so offsetY = 120 works
|
|
959
|
-
|
|
960
|
-
|
|
950
|
+
ref.current!.offsetY = 120;
|
|
951
|
+
ref.current!.prevScroll = 200;
|
|
961
952
|
await act(async () => {
|
|
962
|
-
await
|
|
953
|
+
await ref.current!.handleChildScrollEnd();
|
|
963
954
|
});
|
|
964
|
-
expect(
|
|
955
|
+
expect(ref.current!.isRecoiling).toBe(true);
|
|
965
956
|
await act(async () => {
|
|
966
957
|
await new Promise((r) => setTimeout(r, 600));
|
|
967
958
|
});
|
|
968
|
-
expect(
|
|
959
|
+
expect(ref.current!.isRecoiling).toBe(false);
|
|
969
960
|
});
|
|
970
961
|
});
|
|
971
962
|
|
|
@@ -979,16 +970,16 @@ describe("ActionSheet", () => {
|
|
|
979
970
|
</ActionSheet>
|
|
980
971
|
</ThemeProvider>
|
|
981
972
|
);
|
|
982
|
-
|
|
983
|
-
|
|
973
|
+
ref.current!.offsetY = 98;
|
|
974
|
+
ref.current!.prevScroll = 100;
|
|
984
975
|
await act(async () => {
|
|
985
|
-
await
|
|
976
|
+
await ref.current!.handleChildScrollEnd();
|
|
986
977
|
});
|
|
987
|
-
expect(
|
|
978
|
+
expect(ref.current!.isRecoiling).toBe(true);
|
|
988
979
|
await act(async () => {
|
|
989
980
|
await new Promise((r) => setTimeout(r, 600));
|
|
990
981
|
});
|
|
991
|
-
expect(
|
|
982
|
+
expect(ref.current!.isRecoiling).toBe(false);
|
|
992
983
|
});
|
|
993
984
|
|
|
994
985
|
it("recoils when within scroll threshold of initial position", async () => {
|
|
@@ -1000,7 +991,7 @@ describe("ActionSheet", () => {
|
|
|
1000
991
|
</ActionSheet>
|
|
1001
992
|
</ThemeProvider>
|
|
1002
993
|
);
|
|
1003
|
-
const instance = ref.current
|
|
994
|
+
const instance = ref.current!;
|
|
1004
995
|
instance.actionSheetHeight = 500;
|
|
1005
996
|
instance.prevScroll = 300;
|
|
1006
997
|
instance.offsetY = 250;
|
|
@@ -1026,7 +1017,7 @@ describe("ActionSheet", () => {
|
|
|
1026
1017
|
</ActionSheet>
|
|
1027
1018
|
</ThemeProvider>
|
|
1028
1019
|
);
|
|
1029
|
-
const instance = ref.current
|
|
1020
|
+
const instance = ref.current!;
|
|
1030
1021
|
instance.actionSheetHeight = 500;
|
|
1031
1022
|
instance.prevScroll = 300;
|
|
1032
1023
|
instance.offsetY = 100;
|
|
@@ -1048,7 +1039,7 @@ describe("ActionSheet", () => {
|
|
|
1048
1039
|
</ActionSheet>
|
|
1049
1040
|
</ThemeProvider>
|
|
1050
1041
|
);
|
|
1051
|
-
const instance = ref.current
|
|
1042
|
+
const instance = ref.current!;
|
|
1052
1043
|
instance.actionSheetHeight = 500;
|
|
1053
1044
|
instance.prevScroll = 300;
|
|
1054
1045
|
instance.offsetY = 290;
|
|
@@ -1072,7 +1063,7 @@ describe("ActionSheet", () => {
|
|
|
1072
1063
|
</ActionSheet>
|
|
1073
1064
|
</ThemeProvider>
|
|
1074
1065
|
);
|
|
1075
|
-
const instance = ref.current
|
|
1066
|
+
const instance = ref.current!;
|
|
1076
1067
|
instance.prevScroll = 200;
|
|
1077
1068
|
instance.offsetY = 195;
|
|
1078
1069
|
instance._scrollTo = mock(() => {});
|
|
@@ -1100,14 +1091,12 @@ describe("ActionSheet", () => {
|
|
|
1100
1091
|
</ThemeProvider>
|
|
1101
1092
|
);
|
|
1102
1093
|
await act(async () => {
|
|
1103
|
-
|
|
1104
|
-
nativeEvent: {layout: {height: 800, width: 400}},
|
|
1105
|
-
});
|
|
1094
|
+
ref.current!._onDeviceLayout(layoutEvent(800, 400));
|
|
1106
1095
|
// measure() has a 100ms timeout on iOS; on android it uses StatusBar.currentHeight
|
|
1107
1096
|
await new Promise((r) => setTimeout(r, 200));
|
|
1108
1097
|
});
|
|
1109
1098
|
// The callback should have run and set deviceLayoutCalled
|
|
1110
|
-
expect(
|
|
1099
|
+
expect(ref.current!.deviceLayoutCalled).toBe(true);
|
|
1111
1100
|
});
|
|
1112
1101
|
|
|
1113
1102
|
it("updates state after layout timeout fires without drawUnderStatusBar on android", async () => {
|
|
@@ -1120,12 +1109,10 @@ describe("ActionSheet", () => {
|
|
|
1120
1109
|
</ThemeProvider>
|
|
1121
1110
|
);
|
|
1122
1111
|
await act(async () => {
|
|
1123
|
-
|
|
1124
|
-
nativeEvent: {layout: {height: 900, width: 400}},
|
|
1125
|
-
});
|
|
1112
|
+
ref.current!._onDeviceLayout(layoutEvent(900, 400));
|
|
1126
1113
|
await new Promise((r) => setTimeout(r, 200));
|
|
1127
1114
|
});
|
|
1128
|
-
expect(
|
|
1115
|
+
expect(ref.current!.deviceLayoutCalled).toBe(true);
|
|
1129
1116
|
});
|
|
1130
1117
|
});
|
|
1131
1118
|
});
|