1 | import * as rp from 'request-promise';
|
2 |
|
3 | import AccountsOAuthInstagram from '../src';
|
4 |
|
5 |
|
6 |
|
7 | jest.mock('request-promise');
|
8 |
|
9 | const rpResult = JSON.stringify({
|
10 | data: {
|
11 | id: 'id',
|
12 | username: 'username',
|
13 | profile_picture: 'profile_picture',
|
14 | access_token: 'access_token',
|
15 | },
|
16 | });
|
17 |
|
18 | rp.mockResolvedValue(rpResult);
|
19 |
|
20 | const instagramProvider = new AccountsOAuthInstagram();
|
21 |
|
22 | const params = { access_token: 'test' };
|
23 |
|
24 | describe('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 | });
|