Skip to content

Commit

Permalink
Add mock for navigator global (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xabadu authored May 25, 2018
1 parent 7215e77 commit 3deeec3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You can also check the [Example App](https://github.com/Xabadu/react-native-jest

Mocks currently included:

* Geolocation
* navigator global
* Linking
* ScrollView
* YellowBox
Expand Down
20 changes: 8 additions & 12 deletions src/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,14 @@ module.exports = {
}
});

/* Geolocation, required by the navigation global */
jest.mock('Geolocation', () => ({
clearWatch: jest.fn(),
getCurrentPosition: jest.genMockFn().mockReturnValue({
city: 'San Francisco',
state: 'CA',
lat: 37.785834,
lng: -122.406417
}),
stopObserving: jest.fn(),
watchPosition: jest.fn()
}));
global.navigator = {
geolocation: {
clearWatch: jest.fn(),
getCurrentPosition: jest.fn(),
stopObserving: jest.fn(),
watchPosition: jest.fn()
}
};

jest.mock('ScrollView', () => jest.genMockFromModule('ScrollView'));
jest.mock('YellowBox', () => jest.genMockFromModule('YellowBox'));
Expand Down

0 comments on commit 3deeec3

Please sign in to comment.