Skip to content

Commit 08eecba

Browse files
authored
test: Adds snapshot tests (#4379)
1 parent 8709a48 commit 08eecba

File tree

2 files changed

+929
-8
lines changed

2 files changed

+929
-8
lines changed

packages/core/test/feedback/FeedbackForm.test.tsx

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as React from 'react';
44
import { Alert } from 'react-native';
55

66
import { FeedbackForm } from '../../src/js/feedback/FeedbackForm';
7-
import type { FeedbackFormProps } from '../../src/js/feedback/FeedbackForm.types';
7+
import type { FeedbackFormProps, FeedbackFormStyles } from '../../src/js/feedback/FeedbackForm.types';
88

99
const mockOnFormClose = jest.fn();
1010
const mockGetUser = jest.fn(() => ({
@@ -25,26 +25,80 @@ jest.mock('@sentry/core', () => ({
2525
const defaultProps: FeedbackFormProps = {
2626
onFormClose: mockOnFormClose,
2727
formTitle: 'Feedback Form',
28-
nameLabel: 'Name',
28+
nameLabel: 'Name Label',
2929
namePlaceholder: 'Name Placeholder',
30-
emailLabel: 'Email',
30+
emailLabel: 'Email Label',
3131
emailPlaceholder: 'Email Placeholder',
32-
messageLabel: 'Description',
33-
messagePlaceholder: 'Description Placeholder',
34-
submitButtonLabel: 'Submit',
35-
cancelButtonLabel: 'Cancel',
36-
isRequiredLabel: '(required)',
32+
messageLabel: 'Message Label',
33+
messagePlaceholder: 'Message Placeholder',
34+
submitButtonLabel: 'Submit Button Label',
35+
cancelButtonLabel: 'Cancel Button Label',
36+
isRequiredLabel: '(is required label)',
3737
errorTitle: 'Error',
3838
formError: 'Please fill out all required fields.',
3939
emailError: 'The email address is not valid.',
4040
successMessageText: 'Feedback success',
4141
};
4242

43+
const customStyles: FeedbackFormStyles = {
44+
container: {
45+
backgroundColor: '#ffffff',
46+
},
47+
title: {
48+
fontSize: 20,
49+
color: '#ff0000',
50+
},
51+
label: {
52+
fontSize: 15,
53+
color: '#00ff00',
54+
},
55+
input: {
56+
height: 50,
57+
borderColor: '#0000ff',
58+
fontSize: 13,
59+
color: '#000000',
60+
},
61+
textArea: {
62+
height: 50,
63+
color: '#00ff00',
64+
},
65+
submitButton: {
66+
backgroundColor: '#ffff00',
67+
},
68+
submitText: {
69+
color: '#ff0000',
70+
fontSize: 12,
71+
},
72+
cancelButton: {
73+
paddingVertical: 10,
74+
},
75+
cancelText: {
76+
color: '#ff0000',
77+
fontSize: 10,
78+
},
79+
};
80+
4381
describe('FeedbackForm', () => {
4482
afterEach(() => {
4583
jest.clearAllMocks();
4684
});
4785

86+
it('matches the snapshot with default configuration', () => {
87+
const { toJSON } = render(<FeedbackForm/>);
88+
expect(toJSON()).toMatchSnapshot();
89+
});
90+
91+
it('matches the snapshot with custom texts', () => {
92+
const { toJSON } = render(<FeedbackForm {...defaultProps}/>);
93+
expect(toJSON()).toMatchSnapshot();
94+
});
95+
96+
it('matches the snapshot with custom styles', () => {
97+
const customStyleProps = {styles: customStyles};
98+
const { toJSON } = render(<FeedbackForm {...customStyleProps}/>);
99+
expect(toJSON()).toMatchSnapshot();
100+
});
101+
48102
it('renders correctly', () => {
49103
const { getByPlaceholderText, getByText, getByTestId } = render(<FeedbackForm {...defaultProps} />);
50104

0 commit comments

Comments
 (0)