-
Notifications
You must be signed in to change notification settings - Fork 171
Expand file tree
/
Copy pathButtonV1.test.tsx
More file actions
86 lines (72 loc) · 2.96 KB
/
ButtonV1.test.tsx
File metadata and controls
86 lines (72 loc) · 2.96 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
import * as React from 'react';
import { Button } from '../src/Button';
import * as renderer from 'react-test-renderer';
import { checkRenderConsistency, checkReRender } from '@fluentui-react-native/test-tools';
import { Pressable, Text } from 'react-native';
import { Icon } from '@fluentui-react-native/icon';
export const buttonV1Tests = () => {
describe('Button component tests', () => {
it('Button default', () => {
const tree = renderer.create(<Button>Default Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button disabled', () => {
const tree = renderer.create(<Button disabled>Disabled Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button primary', () => {
const tree = renderer.create(<Button appearance="primary">Primary Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button subtle', () => {
const tree = renderer.create(<Button appearance="subtle">Subtle Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button circular', () => {
const tree = renderer.create(<Button shape="circular">Circular Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button square', () => {
const tree = renderer.create(<Button shape="square">Square Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button small', () => {
const tree = renderer.create(<Button size="small">Small Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button large', () => {
const tree = renderer.create(<Button size="large">Large Button</Button>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button customized', () => {
const CustomButton = Button.customize({ backgroundColor: 'pink' });
const tree = renderer.create(<CustomButton>Custom Button</CustomButton>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button composed', () => {
const ComposedButton = Button.compose({
slots: {
root: Pressable,
icon: Icon,
content: Text,
},
});
const tree = renderer.create(<ComposedButton>Composed Button with RNText</ComposedButton>).toJSON();
expect(tree).toMatchSnapshot();
});
it('Button simple rendering does not invalidate styling', () => {
checkRenderConsistency(() => <Button>Default button</Button>, 2);
});
it('Button re-renders correctly', () => {
checkReRender(() => <Button>Render twice</Button>, 2);
});
it('Button shares produced styles across multiple renders', () => {
const style = { backgroundColor: 'black' };
checkRenderConsistency(() => <Button style={style}>Shared styles</Button>, 2);
});
it('Button re-renders correctly with style', () => {
const style = { borderColor: 'blue' };
checkReRender(() => <Button style={style}>Shared Style Render</Button>, 2);
});
});
};