-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
53bceb0
commit a073613
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-domain-api.test.ts
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,37 @@ | ||
import { ElasticSipTrunkingDomainApi } from '../../../src/rest/v1/elastic-sip-trunking-domain-api'; | ||
import { ApiHostname, UnifiedCredentials } from '@sinch/sdk-client'; | ||
|
||
describe('Elastic SIP Trunking API', () => { | ||
let elasticSipTrunkingApi: ElasticSipTrunkingDomainApi; | ||
let params: UnifiedCredentials & Pick<ApiHostname, 'elasticSipTrunkingHostname'>; | ||
const CUSTOM_HOSTNAME = 'https://new.host.name'; | ||
|
||
beforeEach(() => { | ||
params = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
}); | ||
|
||
it('should initialize the client with the default hostname', () => { | ||
elasticSipTrunkingApi = new ElasticSipTrunkingDomainApi(params, 'dummy'); | ||
elasticSipTrunkingApi.getSinchClient(); | ||
expect(elasticSipTrunkingApi.client).toBeDefined(); | ||
expect(elasticSipTrunkingApi.client?.apiClientOptions.hostname).toBe('https://elastic-trunking.api.sinch.com'); | ||
}); | ||
|
||
it('should use the hostname parameter', () => { | ||
params.elasticSipTrunkingHostname = CUSTOM_HOSTNAME; | ||
elasticSipTrunkingApi = new ElasticSipTrunkingDomainApi(params, 'dummy'); | ||
elasticSipTrunkingApi.getSinchClient(); | ||
expect(elasticSipTrunkingApi.client?.apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
|
||
it('should set a custom URL', () => { | ||
elasticSipTrunkingApi = new ElasticSipTrunkingDomainApi(params, 'dummy'); | ||
elasticSipTrunkingApi.setHostname(CUSTOM_HOSTNAME); | ||
expect(elasticSipTrunkingApi.client).toBeDefined(); | ||
expect(elasticSipTrunkingApi.client?.apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
packages/elastic-sip-trunking/tests/rest/v1/elastic-sip-trunking-service.test.ts
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,62 @@ | ||
import { SinchClientParameters } from '@sinch/sdk-client'; | ||
import { | ||
AccessControlListApi, CallsHistoryApi, | ||
CountryPermissionsApi, | ||
ElasticSipTrunkingService, | ||
SipEndpointsApi, | ||
SipTrunksApi, | ||
} from '../../../src'; | ||
|
||
describe('Elastic SIP Trunking Service', () => { | ||
const DEFAULT_HOSTNAME = 'https://elastic-trunking.api.sinch.com'; | ||
const CUSTOM_HOSTNAME = 'https://new.host.name'; | ||
|
||
it('should initialize the APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const elasticSipTrunkingService = new ElasticSipTrunkingService(params); | ||
|
||
// Then | ||
expect(elasticSipTrunkingService.sipTrunks).toBeInstanceOf(SipTrunksApi); | ||
expect(elasticSipTrunkingService.sipEndpoints).toBeInstanceOf(SipEndpointsApi); | ||
expect(elasticSipTrunkingService.accessControlList).toBeInstanceOf(AccessControlListApi); | ||
expect(elasticSipTrunkingService.countryPermissions).toBeInstanceOf(CountryPermissionsApi); | ||
expect(elasticSipTrunkingService.calls).toBeInstanceOf(CallsHistoryApi); | ||
expect(elasticSipTrunkingService.sipTrunks.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(elasticSipTrunkingService.sipEndpoints.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(elasticSipTrunkingService.accessControlList.getSinchClient().apiClientOptions.hostname) | ||
.toBe(DEFAULT_HOSTNAME); | ||
expect(elasticSipTrunkingService.countryPermissions.getSinchClient().apiClientOptions.hostname) | ||
.toBe(DEFAULT_HOSTNAME); | ||
expect(elasticSipTrunkingService.calls.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
}); | ||
|
||
it('should set a custom hostname for all AOPIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
const elasticSipTrunkingService = new ElasticSipTrunkingService(params); | ||
|
||
// When | ||
elasticSipTrunkingService.setHostname(CUSTOM_HOSTNAME); | ||
|
||
// Then | ||
expect(elasticSipTrunkingService.sipTrunks.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(elasticSipTrunkingService.sipEndpoints.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(elasticSipTrunkingService.accessControlList.getSinchClient().apiClientOptions.hostname) | ||
.toBe(CUSTOM_HOSTNAME); | ||
expect(elasticSipTrunkingService.countryPermissions.getSinchClient().apiClientOptions.hostname) | ||
.toBe(CUSTOM_HOSTNAME); | ||
expect(elasticSipTrunkingService.calls.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
|
||
}); |