-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from shashi-pp/feature/user_authorization
Feature/user authorization
- Loading branch information
Showing
6 changed files
with
137 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { payPayRestSDK } from "../src/lib/paypay-rest-sdk"; | ||
import { httpsClient } from '../src/lib/httpsClient'; | ||
|
||
const conf = { | ||
clientId: '5345435fsdfsr54353454', | ||
clientSecret: 'dgfgdfgt46435gsdr35tte5', | ||
merchantId: '2473982', | ||
productionMode: false | ||
}; | ||
|
||
payPayRestSDK.configure(conf); | ||
|
||
test('Unit Test - Get User Authorization Status', async () => { | ||
const userAuthorizationId = [6787435345]; | ||
const response = { | ||
"resultInfo": { | ||
"code": "SUCCESS", | ||
"message": "Success", | ||
"codeId": "08100001" | ||
}, | ||
"data": { | ||
"userAuthorizationId": "6787435345", | ||
"referenceIds": [ ], | ||
"status": "ACTIVE", | ||
"scopes": [ | ||
"continuous_payments" | ||
], | ||
"expireAt": 34534543534, | ||
"issuedAt": 45353535343 | ||
} | ||
}; | ||
|
||
const mockHttpsCall = jest.spyOn(httpsClient, 'httpsCall'); | ||
mockHttpsCall.mockImplementation(jest.fn((_options: any, _payload = '', _callback: any) => { | ||
_callback(response); | ||
})); | ||
|
||
await payPayRestSDK.getUserAuthorizationStatus(userAuthorizationId, (result: any) => { | ||
expect(result).toEqual(response); | ||
}); | ||
|
||
expect(mockHttpsCall).toHaveBeenCalledTimes(1); | ||
|
||
mockHttpsCall.mockClear(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { payPayRestSDK } from "../src/lib/paypay-rest-sdk"; | ||
import { httpsClient } from '../src/lib/httpsClient'; | ||
|
||
const conf = { | ||
clientId: '5345435fsdfsr54353454', | ||
clientSecret: 'dgfgdfgt46435gsdr35tte5', | ||
merchantId: '2473982', | ||
productionMode: false | ||
}; | ||
|
||
payPayRestSDK.configure(conf); | ||
|
||
test('Unit Test - Unlink user', async () => { | ||
const userAuthorizationId = [6787435345]; | ||
const response = { | ||
"resultInfo": { | ||
"code": "SUCCESS", | ||
"message": "Success", | ||
"codeId": "08100001" | ||
} | ||
}; | ||
|
||
const mockHttpsCall = jest.spyOn(httpsClient, 'httpsCall'); | ||
mockHttpsCall.mockImplementation(jest.fn((_options: any, _payload = '', _callback: any) => { | ||
_callback(response); | ||
})); | ||
|
||
await payPayRestSDK.unlinkUser(userAuthorizationId, (result: any) => { | ||
expect(result).toEqual(response); | ||
}); | ||
|
||
expect(mockHttpsCall).toHaveBeenCalledTimes(1); | ||
|
||
mockHttpsCall.mockClear(); | ||
}); |