-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathFAB.test.tsx
More file actions
67 lines (58 loc) · 1.86 KB
/
FAB.test.tsx
File metadata and controls
67 lines (58 loc) · 1.86 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
import * as React from 'react';
import { FAB } from '../src/FAB/FAB';
import { checkRenderConsistency, checkReRender } from '@fluentui-react-native/test-tools';
import * as renderer from 'react-test-renderer';
const fontBuiltInProps = {
fontFamily: 'Arial',
codepoint: 0x2663,
fontSize: 16,
};
const iconProps = { fontSource: { ...fontBuiltInProps }, color: '#fff' };
export const fabTests = () => {
beforeAll(() => {
jest.mock('react-native/Libraries/Utilities/Platform', () => ({
OS: 'ios',
select: () => null,
}));
});
it('Default FAB (iOS)', () => {
const tree = renderer.create(<FAB icon={iconProps}>Default FAB (iOS)</FAB>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Custom FAB with no shadow(iOS)', () => {
const CustomFABNoShadow = FAB.customize({ shadowToken: undefined });
const tree = renderer.create(<CustomFABNoShadow icon={iconProps}>Custom FAB with no shadow(iOS)</CustomFABNoShadow>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button simple rendering does not invalidate styling', () => {
checkRenderConsistency(() => <FAB icon={iconProps}>Default FAB</FAB>, 2);
});
it('FAB re-renders correctly', () => {
checkReRender(() => <FAB icon={iconProps}>Render twice</FAB>, 2);
});
it('FAB shares produced styles across multiple renders', () => {
const style = { backgroundColor: 'black' };
checkRenderConsistency(
() => (
<FAB icon={iconProps} style={style}>
Shared styles
</FAB>
),
2,
);
});
it('FAB re-renders correctly with style', () => {
const style = { borderColor: 'blue' };
checkReRender(
() => (
<FAB icon={iconProps} style={style}>
Shared Style Render
</FAB>
),
2,
);
});
afterAll(() => {
jest.unmock('react-native/Libraries/Utilities/Platform');
});
};