From 20877adb8a35a6024678a684af31bd97152a136d Mon Sep 17 00:00:00 2001 From: Antoine Sein Date: Fri, 5 Apr 2024 14:34:55 +0200 Subject: [PATCH] Add missing test files --- .../fax/tests/rest/v3/fax-service.test.ts | 45 +++++++++++++++++ .../tests/rest/v1/numbers-service.test.ts | 48 +++++++++++++++++++ .../sms/tests/rest/v1/sms-service.test.ts | 48 +++++++++++++++++++ .../rest/v1/verification-service.test.ts | 40 ++++++++++++++++ 4 files changed, 181 insertions(+) create mode 100644 packages/fax/tests/rest/v3/fax-service.test.ts create mode 100644 packages/numbers/tests/rest/v1/numbers-service.test.ts create mode 100644 packages/sms/tests/rest/v1/sms-service.test.ts create mode 100644 packages/verification/tests/rest/v1/verification-service.test.ts diff --git a/packages/fax/tests/rest/v3/fax-service.test.ts b/packages/fax/tests/rest/v3/fax-service.test.ts new file mode 100644 index 00000000..c12860ef --- /dev/null +++ b/packages/fax/tests/rest/v3/fax-service.test.ts @@ -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); + }); +}); diff --git a/packages/numbers/tests/rest/v1/numbers-service.test.ts b/packages/numbers/tests/rest/v1/numbers-service.test.ts new file mode 100644 index 00000000..b9c627ed --- /dev/null +++ b/packages/numbers/tests/rest/v1/numbers-service.test.ts @@ -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); + }); +}); diff --git a/packages/sms/tests/rest/v1/sms-service.test.ts b/packages/sms/tests/rest/v1/sms-service.test.ts new file mode 100644 index 00000000..20940932 --- /dev/null +++ b/packages/sms/tests/rest/v1/sms-service.test.ts @@ -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); + }); +}); diff --git a/packages/verification/tests/rest/v1/verification-service.test.ts b/packages/verification/tests/rest/v1/verification-service.test.ts new file mode 100644 index 00000000..6f6fb07c --- /dev/null +++ b/packages/verification/tests/rest/v1/verification-service.test.ts @@ -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); + }); +});