-
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
a067d3d
commit 20877ad
Showing
4 changed files
with
181 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { SinchClientParameters } from '@sinch/sdk-client'; | ||
import { EmailsApi, FaxesApi, FaxService, ServicesApi } from '../../../src'; | ||
|
||
describe('Fax Service', () => { | ||
const DEFAULT_HOSTNAME = 'https://fax.api.sinch.com'; | ||
const CUSTOM_HOSTNAME = 'https://new.host.name'; | ||
|
||
it('should initialize all the APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const faxService = new FaxService(params); | ||
|
||
// Then | ||
expect(faxService.faxes).toBeInstanceOf(FaxesApi); | ||
expect(faxService.emails).toBeInstanceOf(EmailsApi); | ||
expect(faxService.services).toBeInstanceOf(ServicesApi); | ||
expect(faxService.faxes.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(faxService.emails.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(faxService.services.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
}); | ||
|
||
it('should set a custom hostname for all APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const faxService = new FaxService(params); | ||
faxService.setHostname(CUSTOM_HOSTNAME); | ||
|
||
// Then | ||
expect(faxService.faxes.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(faxService.emails.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(faxService.services.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
}); |
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,48 @@ | ||
import { SinchClientParameters } from '@sinch/sdk-client'; | ||
import { ActiveNumberApi, AvailableNumberApi, AvailableRegionsApi, CallbacksApi, NumbersService } from '../../../src'; | ||
|
||
describe('Numbers Service', () => { | ||
const DEFAULT_HOSTNAME = 'https://numbers.api.sinch.com'; | ||
const CUSTOM_HOSTNAME = 'https://new.host.name'; | ||
|
||
it('should initialize all the APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const numbersService = new NumbersService(params); | ||
|
||
// Then | ||
expect(numbersService.availableRegions).toBeInstanceOf(AvailableRegionsApi); | ||
expect(numbersService.availableNumber).toBeInstanceOf(AvailableNumberApi); | ||
expect(numbersService.activeNumber).toBeInstanceOf(ActiveNumberApi); | ||
expect(numbersService.callbacks).toBeInstanceOf(CallbacksApi); | ||
expect(numbersService.availableRegions.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(numbersService.availableNumber.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(numbersService.activeNumber.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(numbersService.callbacks.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
}); | ||
|
||
it('should set a custom hostname for all APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const numbersService = new NumbersService(params); | ||
numbersService.setHostname(CUSTOM_HOSTNAME); | ||
|
||
// Then | ||
expect(numbersService.availableRegions.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(numbersService.availableNumber.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(numbersService.activeNumber.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(numbersService.callbacks.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
}); |
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,48 @@ | ||
import { SinchClientParameters } from '@sinch/sdk-client'; | ||
import { BatchesApi, DeliveryReportsApi, GroupsApi, InboundsApi, SmsService } from '../../../src'; | ||
|
||
describe('SMS Service', () => { | ||
const DEFAULT_HOSTNAME = 'https://zt.us.sms.api.sinch.com'; | ||
const CUSTOM_HOSTNAME = 'https://new.host.name'; | ||
|
||
it('should initialize all the APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const smsService = new SmsService(params); | ||
|
||
// Then | ||
expect(smsService.batches).toBeInstanceOf(BatchesApi); | ||
expect(smsService.deliveryReports).toBeInstanceOf(DeliveryReportsApi); | ||
expect(smsService.inbounds).toBeInstanceOf(InboundsApi); | ||
expect(smsService.groups).toBeInstanceOf(GroupsApi); | ||
expect(smsService.batches.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(smsService.deliveryReports.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(smsService.inbounds.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(smsService.groups.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
}); | ||
|
||
it('should set a custom hostname for all APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
projectId: 'PROJECT_ID', | ||
keyId: 'KEY_ID', | ||
keySecret: 'KEY_SECRET', | ||
}; | ||
|
||
// When | ||
const smsService = new SmsService(params); | ||
smsService.setHostname(CUSTOM_HOSTNAME); | ||
|
||
// Then | ||
expect(smsService.batches.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(smsService.deliveryReports.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(smsService.inbounds.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(smsService.groups.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
}); |
40 changes: 40 additions & 0 deletions
40
packages/verification/tests/rest/v1/verification-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,40 @@ | ||
import { SinchClientParameters } from '@sinch/sdk-client'; | ||
import { VerificationsApi, VerificationService, VerificationStatusApi } from '../../../src'; | ||
|
||
describe('Verification Service', () => { | ||
const DEFAULT_HOSTNAME = 'https://verification.api.sinch.com'; | ||
const CUSTOM_HOSTNAME = 'https://new.host.name'; | ||
|
||
it('should initialize all the APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
applicationKey: 'APPLICATION_KEY', | ||
applicationSecret: 'APPLICATION_SECRET', | ||
}; | ||
|
||
// When | ||
const verificationService = new VerificationService(params); | ||
|
||
// Then | ||
expect(verificationService.verifications).toBeInstanceOf(VerificationsApi); | ||
expect(verificationService.verificationStatus).toBeInstanceOf(VerificationStatusApi); | ||
expect(verificationService.verifications.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
expect(verificationService.verificationStatus.getSinchClient().apiClientOptions.hostname).toBe(DEFAULT_HOSTNAME); | ||
}); | ||
|
||
it('should set a custom hostname for all APIs', () => { | ||
// Given | ||
const params: SinchClientParameters = { | ||
applicationKey: 'APPLICATION_KEY', | ||
applicationSecret: 'APPLICATION_SECRET', | ||
}; | ||
|
||
// When | ||
const verificationService = new VerificationService(params); | ||
verificationService.setHostname(CUSTOM_HOSTNAME); | ||
|
||
// Then | ||
expect(verificationService.verifications.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
expect(verificationService.verificationStatus.getSinchClient().apiClientOptions.hostname).toBe(CUSTOM_HOSTNAME); | ||
}); | ||
}); |