Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Commit 16b77aa

Browse files
committed
Test that renderTag prop works.
1 parent 9dfe392 commit 16b77aa

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

Tags/__tests__/Tags-tests.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from "react";
22
import renderer from "react-test-renderer";
3+
import { Text } from "react-native";
4+
35
import Tags from "../../";
46

57
describe("Tags", () => {
@@ -18,6 +20,24 @@ describe("Tags", () => {
1820
expect(tree).toMatchSnapshot();
1921
});
2022

23+
describe("renderTag prop", () => {
24+
it("allows me to render a custom tag with a function", () => {
25+
const renderTag = jest.fn(({ tag }) => <Text key={tag}>{tag}</Text>);
26+
27+
const tree = renderer
28+
.create(
29+
<Tags
30+
initialText=""
31+
initialTags={["palm", "oil", "sucks"]}
32+
onChangeTags={noop}
33+
renderTag={renderTag}
34+
/>
35+
)
36+
.toJSON();
37+
expect(tree).toMatchSnapshot();
38+
});
39+
});
40+
2141
describe("textInputProps", () => {
2242
const tree = renderer
2343
.create(

Tags/__tests__/__snapshots__/Tags-tests.js.snap

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,71 @@ exports[` 1`] = `
165165
</View>
166166
`;
167167

168+
exports[`Tags renderTag prop allows me to render a custom tag with a function 1`] = `
169+
<View
170+
style={
171+
Array [
172+
Object {
173+
"alignItems": "center",
174+
"flexDirection": "row",
175+
"flexWrap": "wrap",
176+
},
177+
undefined,
178+
undefined,
179+
]
180+
}
181+
>
182+
<Text>
183+
palm
184+
</Text>
185+
<Text>
186+
oil
187+
</Text>
188+
<Text>
189+
sucks
190+
</Text>
191+
<View
192+
style={
193+
Array [
194+
Object {
195+
"backgroundColor": "#ccc",
196+
"borderRadius": 16,
197+
"flex": 1,
198+
"height": 32,
199+
"margin": 4,
200+
"minWidth": 100,
201+
},
202+
undefined,
203+
]
204+
}
205+
>
206+
<TextInput
207+
allowFontScaling={true}
208+
onChangeText={[Function]}
209+
onSubmitEditing={[Function]}
210+
rejectResponderTermination={true}
211+
style={
212+
Array [
213+
Object {
214+
"color": "rgba(0, 0, 0, 0.87)",
215+
"flex": 1,
216+
"fontSize": 13,
217+
"height": 32,
218+
"margin": 0,
219+
"padding": 0,
220+
"paddingLeft": 12,
221+
"paddingRight": 12,
222+
},
223+
undefined,
224+
]
225+
}
226+
underlineColorAndroid="transparent"
227+
value=""
228+
/>
229+
</View>
230+
</View>
231+
`;
232+
168233
exports[`Tags should render props correctly 1`] = `
169234
<View
170235
style={

0 commit comments

Comments
 (0)