-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyEmail.test.js
38 lines (33 loc) · 1.01 KB
/
MyEmail.test.js
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
import React from 'react';
import { Text, Linking } from 'react-native';
import { render, fireEvent } from 'react-native-testing-library';
import MyEmail from './MyEmail';
describe('component MyEmail', () => {
const email = '[email protected]';
it('renders correctly', () => {
const snapShotTree = render(<MyEmail email={email} />).toJSON();
expect(snapShotTree).toMatchSnapshot();
});
it('should display the passed email', () => {
const App = () => (
<>
<MyEmail email={email} />
</>
);
const wrapper = render(<App />);
const label = wrapper.UNSAFE_getByType(Text);
expect(label.props.children).toStrictEqual(email);
});
it('should open email client', () => {
const App = () => (
<>
<MyEmail email={email} />
</>
);
const spy = jest.spyOn(Linking,'openURL');
const wrapper = render(<App />);
const label = wrapper.UNSAFE_getByType(Text);
fireEvent.press(label);
expect(spy).toHaveBeenCalledWith(`mailto:${email}`)
});
});