Skip to content

Commit

Permalink
Use named export, change test to mock entire module
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertBrand committed Apr 6, 2017
1 parent 1375c95 commit 4ec44e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
View
} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
import { Button } from 'react-native-vector-icons/FontAwesome';

export default function App() {
return (
Expand All @@ -14,9 +15,9 @@ export default function App() {
Welcome fellow traveler!
</Text>
<Icon name="thumbs-up" size={64} color="#9ad3f1" />
<Icon.Button name="facebook" backgroundColor="#3b5998">
<Button name="facebook" backgroundColor="#3b5998">
Login with Facebook
</Icon.Button>
</Button>
</View>
);
}
Expand Down
5 changes: 4 additions & 1 deletion __tests__/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ import App from '../App';

jest.mock('react-native-vector-icons/FontAwesome', () => {
const mockComponent = require('mockComponent').default;
const module = jest.genMockFromModule('react-native-vector-icons/FontAwesome');
const Icon = mockComponent('Icon');
Icon.Button = mockComponent('Icon.Button');
return Icon;
module.default = Icon;
module.Button = Icon.Button;
return module;
});

describe('App', () => {
Expand Down

0 comments on commit 4ec44e2

Please sign in to comment.