Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/workflow/meteor-facebook-fake
A stub for use in testing Meteor apps. Fakes the oauth calls amongst other APIs.
https://github.com/workflow/meteor-facebook-fake
Last synced: 9 days ago
JSON representation
A stub for use in testing Meteor apps. Fakes the oauth calls amongst other APIs.
- Host: GitHub
- URL: https://github.com/workflow/meteor-facebook-fake
- Owner: workflow
- Created: 2015-07-28T09:05:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-05T22:06:43.000Z (over 9 years ago)
- Last Synced: 2024-10-12T00:32:16.065Z (about 1 month ago)
- Language: JavaScript
- Size: 141 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# facebook-fake
A stub for use in testing Meteor apps. Stubs the oauth calls and allows you to fake stub more.## Usage:
If you are using Facebook authentication, add this package like this:
`meteor add dropz:facebook-fake`
Your app will no longer authenticate with Facebook in development mode and will authenticate with
a fake user even if you do not have an internet connection. This package does not affect production
as it is a `debugOnly` package.### Facebook Login
Will intercept your facebook login call and create a fake user with all standard public facebook api data.
### Intercepting graph calls
Currently, only the call to retrieve your own picture gets intercepted.
Here's an example that will get intercepted and populated with a fake Picture.Extending the registering user with the URL to her profile pic during registration:
```js
Meteor.users.requestAdditionalFacebookData = function(user) {
// Public Profile Picture
var facebook = user.services.facebook;
var pictureData = Meteor.http.get('https://graph.facebook.com/me/picture', {
params: {
access_token: facebook.accessToken,
redirect: false,
type: 'large'
}
});
facebook.picture_url = pictureData.data.data.url;return user;
};Accounts.onCreateUser(function(options, user) {
// We still want the default hook's 'profile' behavior.
if (options.profile) {
user.profile = options.profile;
}
if (Dropz.helpers.server.hasConnectedService(user, 'facebook')) {
Meteor.users.requestAdditionalFacebookData(user);
// Do other stuff such as data normalization
}return user;
});
```This package is an example of how to use
[xolvio:http-interceptor](https://github.com/xolvio/meteor-http-interceptor) to test your app.## Thanks
Inspired by and adapted from [xolvio:github-fake](https://github.com/xolvio/meteor-github-stub).