forked from GeekyAnts/NativeBase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionsheet.android.js
More file actions
75 lines (70 loc) · 2.08 KB
/
Actionsheet.android.js
File metadata and controls
75 lines (70 loc) · 2.08 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
import "react-native";
import React from "react";
import renderer from "react-test-renderer";
import { Button } from "./../../src/basic/Button";
import { ActionSheet } from "./../../src/basic/Actionsheet";
import { Text } from "./../../src/basic/Text";
var REGULAR_BUTTONS = ["Option 0", "Option 1", "Option 2", "Delete", "Cancel"];
var DESTRUCTIVE_INDEX = 3;
var CANCEL_INDEX = 4;
var ICON_BUTTONS = [
{ text: "Option 0", icon: "american-football", iconColor: "#2c8ef4" },
{ text: "Option 1", icon: "analytics", iconColor: "#f42ced" },
{ text: "Option 2", icon: "aperture", iconColor: "#ea943b" },
{ text: "Delete", icon: "trash", iconColor: "#fa213b" },
{ text: "Cancel", icon: "close", iconColor: "#25de5b" }
];
// Note: test renderer must be required after react-native.
jest.mock("Platform", () => {
const Platform = require.requireActual("Platform");
Platform.OS = "android";
return Platform;
});
it("renders Regular ActionSheet", () => {
const tree = renderer
.create(
<Button
onPress={() =>
ActionSheet.show(
{
options: REGULAR_BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
title: "Select an option"
},
buttonIndex => {
this.setState({ clicked: REGULAR_BUTTONS[buttonIndex] });
}
)
}
>
<Text>Actionsheet</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});
it("renders Icon ActionSheet", () => {
const tree = renderer
.create(
<Button
onPress={() =>
ActionSheet.show(
{
options: ICON_BUTTONS,
cancelButtonIndex: CANCEL_INDEX,
destructiveButtonIndex: DESTRUCTIVE_INDEX,
title: "Select an option"
},
buttonIndex => {
this.setState({ clicked: ICON_BUTTONS[buttonIndex] });
}
)
}
>
<Text>Actionsheet</Text>
</Button>
)
.toJSON();
expect(tree).toMatchSnapshot();
});