UNPKG

967 BPlain TextView Raw
1import * as rp from 'request-promise';
2
3import AccountsOAuthInstagram from '../src';
4
5// Mock the requestPromise module
6
7jest.mock('request-promise');
8
9const rpResult = JSON.stringify({
10 data: {
11 id: 'id',
12 username: 'username',
13 profile_picture: 'profile_picture',
14 access_token: 'access_token',
15 },
16});
17
18rp.mockResolvedValue(rpResult);
19
20const instagramProvider = new AccountsOAuthInstagram();
21
22const params = { access_token: 'test' };
23
24describe('AccountsOAuthInstagram', () => {
25 describe('authenticate', () => {
26 instagramProvider.authenticate(params);
27 it('should call rp', () => {
28 expect(rp).toHaveBeenCalled();
29 });
30
31 it('should return the user data', () => {
32 instagramProvider.authenticate(params).then(result => {
33 expect(result).toBe({
34 id: 'id',
35 username: 'username',
36 profilePicture: 'profile_picture',
37 accessToken: 'access_token',
38 });
39 });
40 });
41 });
42});