@@ -2,9 +2,8 @@ import nock from 'nock'
2
2
import assert from 'assert'
3
3
import { expect } from 'chai'
4
4
5
- import { mockAuthorize } from './server'
6
-
7
- import { authorize } from '../src'
5
+ import { mockAuthorize } from '../server'
6
+ import { authorize , GrantType } from '../../src'
8
7
9
8
const { PAYU_CLIENT_ID , PAYU_CLIENT_SECRET } = process . env
10
9
@@ -19,7 +18,7 @@ describe('authorize function', () => {
19
18
const response = await authorize ( {
20
19
clientSecret : PAYU_CLIENT_SECRET ,
21
20
clientId : PAYU_CLIENT_ID ,
22
- grantType : 'client_credentials' ,
21
+ grantType : GrantType . ClientCredentials
23
22
} )
24
23
25
24
response . should . have . property ( 'accessToken' )
@@ -32,23 +31,41 @@ describe('authorize function', () => {
32
31
try {
33
32
await authorize ( )
34
33
} catch ( err ) {
35
- should . throw ( ( ) => { throw err } , assert . AssertionError , 'PAYU_CLIENT_ID should not be empty' )
34
+ should . throw (
35
+ ( ) => {
36
+ throw err
37
+ } ,
38
+ assert . AssertionError ,
39
+ 'PAYU_CLIENT_ID should not be empty'
40
+ )
36
41
}
37
42
} )
38
43
39
44
it ( 'should return validation error on PAYU_CLIENT_SECRET when field is not provided' , async ( ) => {
40
45
try {
41
46
await authorize ( { clientId : 2 } )
42
47
} catch ( err ) {
43
- should . throw ( ( ) => { throw err } , assert . AssertionError , 'PAYU_CLIENT_SECRET should not be empty' )
48
+ should . throw (
49
+ ( ) => {
50
+ throw err
51
+ } ,
52
+ assert . AssertionError ,
53
+ 'PAYU_CLIENT_SECRET should not be empty'
54
+ )
44
55
}
45
56
} )
46
57
47
58
it ( 'should return validation error on grantType when field is not provided' , async ( ) => {
48
59
try {
49
60
await authorize ( { clientId : 2 , clientSecret : 2 } )
50
61
} catch ( err ) {
51
- should . throw ( ( ) => { throw err } , assert . AssertionError , 'grantType should not be empty' )
62
+ should . throw (
63
+ ( ) => {
64
+ throw err
65
+ } ,
66
+ assert . AssertionError ,
67
+ 'grantType should not be empty'
68
+ )
52
69
}
53
70
} )
54
71
} )
0 commit comments