-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shangamesh T
committed
Jun 1, 2021
1 parent
b261a0f
commit 21e6bbd
Showing
7 changed files
with
99 additions
and
7 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,69 @@ | ||
'use strict'; | ||
|
||
// Including Required Modules | ||
const helper = require('../../src/clientHelper'); | ||
const assert = require('assert'); | ||
|
||
// Constants | ||
const expectedLiveURI = 'live/v2/serviceName'; | ||
const expectedSandboxURI = 'sandbox/v2/serviceName'; | ||
const expectedUnfiedURI = 'v2/serviceName'; | ||
|
||
// Test cases to validate Environment specific URI | ||
describe('Test Environment specific URI Test cases', () => { | ||
|
||
// Test to validate URI for Live specific URI | ||
it('Testing Live specific URI', (done) => { | ||
const response = helper.prepareOptions(getPayConfig(false), {urlFragment: 'serviceName'}); | ||
assert.strictEqual(response.urlFragment, expectedLiveURI); | ||
done(); | ||
}); | ||
|
||
// Test to validate URI for Sandbox specific URI | ||
it('Testing Sandbox specific URI', (done) => { | ||
const response = helper.prepareOptions(getPayConfig(true), {urlFragment: 'serviceName'}); | ||
assert.strictEqual(response.urlFragment, expectedSandboxURI); | ||
done(); | ||
}); | ||
|
||
// Generic method used to create Pay Configuration | ||
function getPayConfig(sandboxFlag){ | ||
let payConfig = { | ||
'publicKeyId': 'XXXXXXXXXXXXXXXXXXXXXXXX', | ||
'privateKey':'keys/private.pem', | ||
'sandbox': sandboxFlag, | ||
'region': 'us', | ||
}; | ||
return payConfig; | ||
} | ||
}); | ||
|
||
// Test cases to validate Unified Endpoint specific URI | ||
describe('Test Environment specific URI Test cases', () => { | ||
|
||
// Testing Unified endpoint URI by passing Live specific PublicKeyId | ||
it('Testing Unified endpoint URI for Live PublicKeyId', (done) => { | ||
const options = {urlFragment: 'serviceName'}; | ||
const response = helper.prepareOptions(getPayConfig('LIVE-XXXXXXXXXXXXXXXXXXXXXXXX'), {urlFragment: 'serviceName'}); | ||
assert.strictEqual(response.urlFragment, expectedUnfiedURI); | ||
done(); | ||
}); | ||
|
||
// Testing Unified endpoint URI by passing Sandbox specific PublicKeyId | ||
it('Testing Unified endpoint URI for Sandbox PublicKeyId', (done) => { | ||
const options = {urlFragment: 'serviceName'}; | ||
const response = helper.prepareOptions(getPayConfig('SANDBOX-XXXXXXXXXXXXXXXXXXXXXXXX'), {urlFragment: 'serviceName'}); | ||
assert.strictEqual(response.urlFragment, expectedUnfiedURI); | ||
done(); | ||
}); | ||
|
||
// Generic method used to create Pay Configuration | ||
function getPayConfig(publicKeyId){ | ||
let payConfig = { | ||
'publicKeyId': publicKeyId, | ||
'privateKey':'keys/private.pem', | ||
'region': 'us', | ||
}; | ||
return payConfig; | ||
} | ||
}); |