Skip to content

Commit 0d27c73

Browse files
committed
fix: mocks
1 parent f2161fa commit 0d27c73

5 files changed

Lines changed: 130 additions & 3 deletions

File tree

FabricExample/__tests__/__snapshots__/components-rendering.spec.tsx.snap

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,38 @@ exports[`components rendering should render \`OverKeyboardView\` 1`] = `
133133
/>
134134
</OverKeyboardView>
135135
`;
136+
137+
exports[`components rendering should render compound \`KeyboardToolbar\` 1`] = `
138+
[
139+
<View>
140+
<KeyboardToolbar.Background>
141+
<View
142+
style={
143+
{
144+
"backgroundColor": "black",
145+
"height": 20,
146+
"width": 20,
147+
}
148+
}
149+
/>
150+
</KeyboardToolbar.Background>
151+
<KeyboardToolbar.Content>
152+
<View
153+
style={
154+
{
155+
"backgroundColor": "black",
156+
"height": 20,
157+
"width": 20,
158+
}
159+
}
160+
/>
161+
</KeyboardToolbar.Content>
162+
<KeyboardToolbar.Prev />
163+
<KeyboardToolbar.Next />
164+
<KeyboardToolbar.Done />
165+
</View>,
166+
<KeyboardToolbar.Group>
167+
<TextInput />
168+
</KeyboardToolbar.Group>,
169+
]
170+
`;

FabricExample/__tests__/components-rendering.spec.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render } from "@testing-library/react-native";
22
import React from "react";
3-
import { View } from "react-native";
3+
import { TextInput, View } from "react-native";
44
import {
55
KeyboardAvoidingView,
66
KeyboardAwareScrollView,
@@ -68,6 +68,27 @@ function KeyboardToolbarTest() {
6868
return <KeyboardToolbar content={content} />;
6969
}
7070

71+
function KeyboardToolbarCompoundTest() {
72+
return (
73+
<>
74+
<KeyboardToolbar>
75+
<KeyboardToolbar.Background>
76+
<EmptyView />
77+
</KeyboardToolbar.Background>
78+
<KeyboardToolbar.Content>
79+
<EmptyView />
80+
</KeyboardToolbar.Content>
81+
<KeyboardToolbar.Prev />
82+
<KeyboardToolbar.Next />
83+
<KeyboardToolbar.Done />
84+
</KeyboardToolbar>
85+
<KeyboardToolbar.Group>
86+
<TextInput />
87+
</KeyboardToolbar.Group>
88+
</>
89+
);
90+
}
91+
7192
function OverKeyboardViewTest() {
7293
return (
7394
<OverKeyboardView visible={true}>
@@ -109,6 +130,10 @@ describe("components rendering", () => {
109130
expect(render(<KeyboardToolbarTest />)).toMatchSnapshot();
110131
});
111132

133+
it("should render compound `KeyboardToolbar`", () => {
134+
expect(render(<KeyboardToolbarCompoundTest />)).toMatchSnapshot();
135+
});
136+
112137
it("should render `OverKeyboardView`", () => {
113138
expect(render(<OverKeyboardViewTest />)).toMatchSnapshot();
114139
});

example/__tests__/__snapshots__/components-rendering.spec.tsx.snap

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,38 @@ exports[`components rendering should render \`OverKeyboardView\` 1`] = `
142142
/>
143143
</OverKeyboardView>
144144
`;
145+
146+
exports[`components rendering should render compound \`KeyboardToolbar\` 1`] = `
147+
[
148+
<View>
149+
<KeyboardToolbar.Background>
150+
<View
151+
style={
152+
{
153+
"backgroundColor": "black",
154+
"height": 20,
155+
"width": 20,
156+
}
157+
}
158+
/>
159+
</KeyboardToolbar.Background>
160+
<KeyboardToolbar.Content>
161+
<View
162+
style={
163+
{
164+
"backgroundColor": "black",
165+
"height": 20,
166+
"width": 20,
167+
}
168+
}
169+
/>
170+
</KeyboardToolbar.Content>
171+
<KeyboardToolbar.Prev />
172+
<KeyboardToolbar.Next />
173+
<KeyboardToolbar.Done />
174+
</View>,
175+
<KeyboardToolbar.Group>
176+
<TextInput />
177+
</KeyboardToolbar.Group>,
178+
]
179+
`;

example/__tests__/components-rendering.spec.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render } from "@testing-library/react-native";
22
import React from "react";
3-
import { View } from "react-native";
3+
import { TextInput, View } from "react-native";
44
import {
55
KeyboardAvoidingView,
66
KeyboardAwareScrollView,
@@ -68,6 +68,27 @@ function KeyboardToolbarTest() {
6868
return <KeyboardToolbar content={content} />;
6969
}
7070

71+
function KeyboardToolbarCompoundTest() {
72+
return (
73+
<>
74+
<KeyboardToolbar>
75+
<KeyboardToolbar.Background>
76+
<EmptyView />
77+
</KeyboardToolbar.Background>
78+
<KeyboardToolbar.Content>
79+
<EmptyView />
80+
</KeyboardToolbar.Content>
81+
<KeyboardToolbar.Prev />
82+
<KeyboardToolbar.Next />
83+
<KeyboardToolbar.Done />
84+
</KeyboardToolbar>
85+
<KeyboardToolbar.Group>
86+
<TextInput />
87+
</KeyboardToolbar.Group>
88+
</>
89+
);
90+
}
91+
7192
function OverKeyboardViewTest() {
7293
return (
7394
<OverKeyboardView visible={true}>
@@ -109,6 +130,10 @@ describe("components rendering", () => {
109130
expect(render(<KeyboardToolbarTest />)).toMatchSnapshot();
110131
});
111132

133+
it("should render compound `KeyboardToolbar`", () => {
134+
expect(render(<KeyboardToolbarCompoundTest />)).toMatchSnapshot();
135+
});
136+
112137
it("should render `OverKeyboardView`", () => {
113138
expect(render(<OverKeyboardViewTest />)).toMatchSnapshot();
114139
});

jest/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ const mock = {
119119
KeyboardStickyView: View,
120120
KeyboardAvoidingView: View,
121121
KeyboardAwareScrollView: ScrollView,
122-
KeyboardToolbar: View,
122+
KeyboardToolbar: Object.assign(View, {
123+
Background: "KeyboardToolbar.Background",
124+
Content: "KeyboardToolbar.Content",
125+
Prev: "KeyboardToolbar.Prev",
126+
Next: "KeyboardToolbar.Next",
127+
Done: "KeyboardToolbar.Done",
128+
Group: "KeyboardToolbar.Group",
129+
}),
123130
KeyboardChatScrollView: ScrollView,
124131
// themes
125132
DefaultKeyboardToolbarTheme,

0 commit comments

Comments
 (0)