Skip to content

Commit

Permalink
Add missing test files
Browse files Browse the repository at this point in the history
  • Loading branch information
asein-sinch committed Apr 5, 2024
1 parent a067d3d commit 20877ad
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 0 deletions.
45 changes: 45 additions & 0 deletions packages/fax/tests/rest/v3/fax-service.test.ts
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);
});
});
48 changes: 48 additions & 0 deletions packages/numbers/tests/rest/v1/numbers-service.test.ts
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);
});
});
48 changes: 48 additions & 0 deletions packages/sms/tests/rest/v1/sms-service.test.ts
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 packages/verification/tests/rest/v1/verification-service.test.ts
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);
});
});

0 comments on commit 20877ad

Please sign in to comment.