Skip to content

Commit

Permalink
fix: use serviceName property of client ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Zuev committed Feb 16, 2022
1 parent 22ea100 commit 19129f3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/service-endpoints.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ describe('service endpoints', () => {
const serviceName = 'myCustomService';

expect(() => {
getServiceClientEndpoint({ options: { serviceName } } as unknown as MockServiceClientCtor);
getServiceClientEndpoint({ serviceName } as unknown as MockServiceClientCtor);
}).toThrow(`Endpoint for service ${serviceName} is no defined`);
});

it('should throw exception if client class has no serviceName option', () => {
expect(() => {
getServiceClientEndpoint({ options: {} } as unknown as MockServiceClientCtor);
getServiceClientEndpoint({} as unknown as MockServiceClientCtor);
}).toThrow('Unable to retrieve serviceName of provided service client class');
});
});
3 changes: 1 addition & 2 deletions src/service-endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ const SERVICE_ENDPOINTS_LIST: ServiceEndpointsList = [

export const getServiceClientEndpoint = <T extends ServiceDefinition>(generatedClientCtor: GeneratedServiceClientCtor<T>): string => {
const clientCtor = generatedClientCtor as unknown as ServiceClientConstructor;
// eslint-disable-next-line prefer-destructuring
const serviceName: string = clientCtor.options.serviceName as string;
const serviceName: string = clientCtor.serviceName as string;

if (!serviceName) {
throw new Error('Unable to retrieve serviceName of provided service client class');
Expand Down

0 comments on commit 19129f3

Please sign in to comment.