@@ -4,35 +4,16 @@ import axios from "axios";
4
4
import * as tokenUtils from "../../src/utils/tokenUtils" ;
5
5
import MockAdapter from "axios-mock-adapter" ;
6
6
let mock : MockAdapter ;
7
+ import * as patreon from "../mocks/patreonMock" ;
7
8
8
9
const validateToken = ( token : string ) =>
9
10
new RegExp ( / [ A - Z a - z 0 - 9 ] { 40 } | [ A - Z a - z 0 - 9 - ] { 35 } / ) . test ( token ) ;
10
11
11
- const fakePatreonIdentity = {
12
- data : { } ,
13
- links : { } ,
14
- included : [
15
- {
16
- attributes : {
17
- is_monthly : true ,
18
- currently_entitled_amount_cents : 100 ,
19
- patron_status : "active_patron" ,
20
- } ,
21
- id : "id" ,
22
- type : "campaign"
23
- }
24
- ] ,
25
- } ;
26
-
27
12
describe ( "tokenUtils test" , function ( ) {
28
13
before ( function ( ) {
29
14
mock = new MockAdapter ( axios , { onNoMatch : "throwException" } ) ;
30
- mock . onPost ( "https://www.patreon.com/api/oauth2/token" ) . reply ( 200 , {
31
- access_token : "test_access_token" ,
32
- refresh_token : "test_refresh_token" ,
33
- expires_in : 3600 ,
34
- } ) ;
35
- mock . onGet ( / i d e n t i t y / ) . reply ( 200 , fakePatreonIdentity ) ;
15
+ mock . onPost ( "https://www.patreon.com/api/oauth2/token" ) . reply ( 200 , patreon . fakeOauth ) ;
16
+ mock . onGet ( / i d e n t i t y / ) . reply ( 200 , patreon . fakeIdentity ) ;
36
17
} ) ;
37
18
38
19
it ( "Should be able to create patreon token" , function ( done ) {
@@ -51,7 +32,7 @@ describe("tokenUtils test", function() {
51
32
it ( "Should be able to get patreon identity" , function ( done ) {
52
33
if ( ! config ?. patreon ) this . skip ( ) ;
53
34
tokenUtils . getPatreonIdentity ( "fake_access_token" ) . then ( ( result ) => {
54
- assert . deepEqual ( result , fakePatreonIdentity ) ;
35
+ assert . deepEqual ( result , patreon . fakeIdentity ) ;
55
36
done ( ) ;
56
37
} ) ;
57
38
} ) ;
0 commit comments