-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathMenuItem.test.tsx
More file actions
115 lines (101 loc) · 2.87 KB
/
Copy pathMenuItem.test.tsx
File metadata and controls
115 lines (101 loc) · 2.87 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
108
109
110
111
112
113
114
115
import * as React from 'react';
import { render } from '@testing-library/react-native';
import { getTheme } from '../../core/theming';
import { tokens } from '../../theme/tokens';
import Menu from '../Menu/Menu';
import { getMenuItemColor } from '../Menu/utils';
const { stateOpacity } = tokens.md.ref;
describe('Menu Item', () => {
it('renders menu item', () => {
const tree = render(
<>
<Menu.Item leadingIcon="redo" onPress={() => {}} title="Redo" />
<Menu.Item leadingIcon="undo" onPress={() => {}} title="Undo" />
<Menu.Item
leadingIcon="content-cut"
onPress={() => {}}
title="Cut"
disabled
/>
<Menu.Item
leadingIcon="content-copy"
onPress={() => {}}
title="Copy"
disabled
/>
<Menu.Item onPress={() => {}} title="Paste" />
</>
).toJSON();
expect(tree).toMatchSnapshot();
});
it('should have titleMaxFontSizeMultiplier passed to title', () => {
const labelMaxFontSizeMultiplier = 2;
const { getByTestId } = render(
<Menu.Item
titleMaxFontSizeMultiplier={labelMaxFontSizeMultiplier}
leadingIcon="content-cut"
onPress={() => {}}
title="Cut"
/>
);
expect(getByTestId('menu-item-title').props.maxFontSizeMultiplier).toBe(
labelMaxFontSizeMultiplier
);
});
it('accepts different values for accessibilityState', () => {
const { getByTestId } = render(
<Menu.Item
accessibilityState={{ checked: true }}
title="Option 1"
testID="touchable"
/>
);
expect(getByTestId('touchable').props.accessibilityState).toMatchObject({
checked: true,
});
});
});
describe('getMenuItemColor - title color', () => {
it('should return disabled color if disabled, for theme version 3', () => {
expect(
getMenuItemColor({
theme: getTheme(),
disabled: true,
})
).toMatchObject({
titleColor: getTheme().colors.onSurface,
contentOpacity: stateOpacity.disabled,
});
});
it('should return correct theme color, for theme version 3', () => {
expect(
getMenuItemColor({
theme: getTheme(),
})
).toMatchObject({
titleColor: getTheme().colors.onSurface,
});
});
});
describe('getMenuItemColor - icon color', () => {
it('should return disabled color if disabled, for theme version 3', () => {
expect(
getMenuItemColor({
theme: getTheme(),
disabled: true,
})
).toMatchObject({
iconColor: getTheme().colors.onSurfaceVariant,
contentOpacity: stateOpacity.disabled,
});
});
it('should return correct theme color, for theme version 3', () => {
expect(
getMenuItemColor({
theme: getTheme(),
})
).toMatchObject({
iconColor: getTheme().colors.onSurfaceVariant,
});
});
});