-
Notifications
You must be signed in to change notification settings - Fork 772
Expand file tree
/
Copy pathRepositoryProfile.js
More file actions
83 lines (69 loc) · 2.16 KB
/
Copy pathRepositoryProfile.js
File metadata and controls
83 lines (69 loc) · 2.16 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
import React from 'react';
import { shallow } from 'enzyme';
import { Icon } from 'react-native-elements';
import { RepositoryProfile } from 'components';
const defaultProps = {
repository: {
fork: true,
parent: true,
language: 'en',
},
starred: false,
navigation: {
navigate() {},
},
loading: false,
subscribed: false,
locale: 'en',
};
describe('<RepositoryProfile />', () => {
it('should render the Icon component if loading is false and repository language is not null', () => {
const wrapper = shallow(
<RepositoryProfile {...defaultProps} language={false} />
);
const theIcon = wrapper.find({ name: 'fiber-manual-record' });
expect(theIcon.length).toBeTruthy();
});
it('should not render the Icon component if loading is true', () => {
const wrapper = shallow(
<RepositoryProfile {...defaultProps} loading={true} />
);
const theIcon = wrapper.find({ name: 'fiber-manual-record' });
expect(theIcon.length).toBeFalsy();
});
it('should not render the Icon component if repository language is null', () => {
const wrapper = shallow(
<RepositoryProfile
{...defaultProps}
repository={{
...defaultProps.repository,
language: null,
}}
/>
);
const theIcon = wrapper.find({ name: 'fiber-manual-record' });
expect(theIcon.length).toBeFalsy();
});
it('should render repository fork text container if repository.fork is true', () => {
const wrapper = shallow(<RepositoryProfile {...defaultProps} />);
const repositoryContainer = wrapper.find({
nativeId: 'repository-fork-container',
});
expect(repositoryContainer.length).toBeTruthy();
});
it('should call navigation.navigate onPress repository parent', () => {
const navigateMock = jest.fn();
const navigation = {
navigate: navigateMock,
};
const wrapper = shallow(
<RepositoryProfile {...defaultProps} navigation={navigation} />
);
wrapper
.find({ nativeId: 'repository-navigate-container' })
.simulate('press');
expect(navigateMock).toHaveBeenCalledWith('Repository', {
repository: true,
});
});
});