-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathfreeze.android.spec.ts
More file actions
107 lines (88 loc) · 2.42 KB
/
Copy pathfreeze.android.spec.ts
File metadata and controls
107 lines (88 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { sv } from "../../../../__fixtures__/sv";
import {
type Handlers,
KEYBOARD,
createRender,
flushAnimatedReactions,
mockLayout,
mockOffset,
mockScrollTo,
mockSize,
setupBeforeEach,
} from "../__fixtures__/testUtils";
const render = createRender("../index.ts");
let handlers: Handlers = {
onStart: jest.fn(),
onMove: jest.fn(),
onInteractive: jest.fn(),
onEnd: jest.fn(),
};
jest.mock("../../../../hooks", () => ({
useKeyboardHandler: jest.fn((h: Handlers) => {
handlers = h;
}),
useResizeMode: jest.fn(),
}));
jest.mock("../../../hooks/useScrollState", () => ({
__esModule: true,
default: jest.fn(() => ({
offset: mockOffset,
layout: mockLayout,
size: mockSize,
})),
}));
beforeEach(() => {
setupBeforeEach();
});
describe("`useChatKeyboard` — Android freeze", () => {
it("should not call scrollTo on keyboard open", () => {
mockOffset.value = 100;
render({
inverted: false,
keyboardLiftBehavior: "always",
freeze: true,
});
handlers.onStart({ height: KEYBOARD });
handlers.onMove({ height: 200 });
expect(mockScrollTo).not.toHaveBeenCalled();
});
it("should not change padding on inverted keyboard open", () => {
const { result } = render({
inverted: true,
keyboardLiftBehavior: "always",
freeze: true,
});
handlers.onStart({ height: KEYBOARD });
handlers.onMove({ height: 200 });
expect(result.current.padding.value).toBe(0);
});
it("should not change padding in onEnd", () => {
const { result } = render({
inverted: false,
keyboardLiftBehavior: "always",
freeze: true,
});
handlers.onEnd({ height: KEYBOARD });
expect(result.current.padding.value).toBe(0);
});
it("should apply the latest frozen keyboard padding when unfrozen", () => {
const freeze = sv(false);
const { result } = render({
inverted: false,
keyboardLiftBehavior: "always",
freeze,
});
handlers.onStart({ height: KEYBOARD });
handlers.onEnd({ height: KEYBOARD });
expect(result.current.padding.value).toBe(KEYBOARD);
freeze.value = true;
flushAnimatedReactions();
handlers.onStart({ height: 0 });
handlers.onMove({ height: 120 });
handlers.onEnd({ height: 0 });
expect(result.current.padding.value).toBe(KEYBOARD);
freeze.value = false;
flushAnimatedReactions();
expect(result.current.padding.value).toBe(0);
});
});