Skip to content

Commit 89355fb

Browse files
committed
fix: mocks
1 parent 40c7de4 commit 89355fb

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
@@ -122,7 +122,14 @@ const mock = {
122122
KeyboardStickyView: View,
123123
KeyboardAvoidingView: View,
124124
KeyboardAwareScrollView: ScrollView,
125-
KeyboardToolbar: View,
125+
KeyboardToolbar: Object.assign(View, {
126+
Background: "KeyboardToolbar.Background",
127+
Content: "KeyboardToolbar.Content",
128+
Prev: "KeyboardToolbar.Prev",
129+
Next: "KeyboardToolbar.Next",
130+
Done: "KeyboardToolbar.Done",
131+
Group: "KeyboardToolbar.Group",
132+
}),
126133
KeyboardChatScrollView: ScrollView,
127134
// themes
128135
DefaultKeyboardToolbarTheme,

0 commit comments

Comments
 (0)