rename type and class, fix test

This commit is contained in:
Samira Mokaram
2020-12-01 13:46:46 +01:00
parent 49938595bc
commit 04a53de52f
8 changed files with 15 additions and 31 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ createApiFactory({
api: pagerDutyApiRef,
deps: { discoveryApi: discoveryApiRef },
factory: ({ discoveryApi }) =>
new PagerDutyClientApi({
new PagerDutyClient({
discoveryApi: discoveryApi,
eventUrl: "https://events.pagerduty.com/v2" //to override the default value
}),
+3 -3
View File
@@ -17,7 +17,7 @@
import { createApiRef } from '@backstage/core';
import { Service, Incident, OnCall } from '../components/types';
import {
PagerDutyClient,
PagerDutyApi,
TriggerAlarmRequest,
ServicesResponse,
IncidentsResponse,
@@ -28,12 +28,12 @@ import {
export class UnauthorizedError extends Error {}
export const pagerDutyApiRef = createApiRef<PagerDutyClient>({
export const pagerDutyApiRef = createApiRef<PagerDutyApi>({
id: 'plugin.pagerduty.api',
description: 'Used to fetch data from PagerDuty API',
});
export class PagerDutyClientApi implements PagerDutyClient {
export class PagerDutyClient implements PagerDutyApi {
constructor(private readonly config: ClientApiConfig) {}
async getServiceByIntegrationKey(integrationKey: string): Promise<Service[]> {
+2 -6
View File
@@ -14,9 +14,5 @@
* limitations under the License.
*/
export {
PagerDutyClientApi,
pagerDutyApiRef,
UnauthorizedError,
} from './client';
export type { PagerDutyClient } from './types';
export { PagerDutyClient, pagerDutyApiRef, UnauthorizedError } from './client';
export type { PagerDutyApi } from './types';
+1 -1
View File
@@ -24,7 +24,7 @@ export type TriggerAlarmRequest = {
userName: string;
};
export interface PagerDutyClient {
export interface PagerDutyApi {
/**
* Fetches a list of services, filtered by the provided integration key.
*
@@ -35,11 +35,7 @@ describe('Incidents', () => {
const { getByText, queryByTestId } = render(
wrapInTestApp(
<ApiProvider apis={apis}>
<Incidents
serviceId="abc"
onTriggerRefresh={false}
setShouldRefreshIncidents={() => {}}
/>
<Incidents serviceId="abc" refreshIncidents={false} />
</ApiProvider>,
),
);
@@ -99,11 +95,7 @@ describe('Incidents', () => {
} = render(
wrapInTestApp(
<ApiProvider apis={apis}>
<Incidents
serviceId="abc"
onTriggerRefresh={false}
setShouldRefreshIncidents={() => {}}
/>
<Incidents serviceId="abc" refreshIncidents={false} />
</ApiProvider>,
),
);
@@ -129,11 +121,7 @@ describe('Incidents', () => {
const { getByText, queryByTestId } = render(
wrapInTestApp(
<ApiProvider apis={apis}>
<Incidents
serviceId="abc"
onTriggerRefresh={false}
setShouldRefreshIncidents={() => {}}
/>
<Incidents serviceId="abc" refreshIncidents={false} />
</ApiProvider>,
),
);
@@ -15,7 +15,7 @@
*/
import React from 'react';
import { render, waitFor, fireEvent } from '@testing-library/react';
import { PagerDutyCard } from './PagerdutyCard';
import { PagerDutyCard } from './PagerDutyCard';
import { Entity } from '@backstage/catalog-model';
import { wrapInTestApp } from '@backstage/test-utils';
import {
+2 -2
View File
@@ -17,9 +17,9 @@ export { plugin } from './plugin';
export {
isPluginApplicableToEntity,
PagerDutyCard,
} from './components/PagerdutyCard';
} from './components/PagerDutyCard';
export {
PagerDutyClientApi,
PagerDutyClient,
pagerDutyApiRef,
UnauthorizedError,
} from './api/client';
+2 -2
View File
@@ -19,7 +19,7 @@ import {
createRouteRef,
discoveryApiRef,
} from '@backstage/core';
import { pagerDutyApiRef, PagerDutyClientApi } from './api';
import { pagerDutyApiRef, PagerDutyClient } from './api';
export const rootRouteRef = createRouteRef({
path: '/pagerduty',
@@ -33,7 +33,7 @@ export const plugin = createPlugin({
api: pagerDutyApiRef,
deps: { discoveryApi: discoveryApiRef },
factory: ({ discoveryApi }) =>
new PagerDutyClientApi({
new PagerDutyClient({
discoveryApi: discoveryApi,
}),
}),