Skip to content

Commit

Permalink
fix(coral): Remove superfluous undefined handling
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu Anderson <[email protected]>
  • Loading branch information
Mathieu Anderson committed Jan 9, 2024
1 parent 9bbf9c8 commit b9d3bde
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 31 deletions.
18 changes: 0 additions & 18 deletions coral/src/domain/requests/requests-transformers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ const mockedRequestsWaitingForApprovalMissingAcl: RequestsWaitingForApprovalWith
TOTAL_NOTIFICATIONS: 8,
};

const defaultRecord = {
TOPIC: 0,
ACL: 0,
SCHEMA: 0,
CONNECTOR: 0,
USER: 0,
OPERATIONAL: 0,
TOTAL_NOTIFICATIONS: 0,
};

const mockApiResponse: KlawApiResponse<"getRequestStatistics"> = {
requestEntityStatistics: [
{
Expand Down Expand Up @@ -381,14 +371,6 @@ describe("request-transformers.ts", () => {
expect(response).toEqual(mockedRequestsWaitingForApproval);
});

it("should return record with default data if API response is undefined", () => {
const response = getRequestsWaitingForApprovalTransformer({
requestEntityStatistics: undefined,
});

expect(response).toEqual(defaultRecord);
});

it("should return record with default data for single entity type if API response misses that data", () => {
const response = getRequestsWaitingForApprovalTransformer(
mockApiResponseMissingAcl
Expand Down
11 changes: 0 additions & 11 deletions coral/src/domain/requests/requests-transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,9 @@ const getRequestsWaitingForApprovalTransformer = (
TOTAL_NOTIFICATIONS: 0,
};

if (requestEntityStatistics === undefined) {
return requestsWaitingForApproval;
}

requestEntityStatistics.forEach((statistics) => {
const { requestEntityType, requestStatusCountSet } = statistics;

if (
requestEntityType === undefined ||
requestStatusCountSet === undefined
) {
return;
}

const amountOfRequestsForEntity =
requestStatusCountSet.find(
(requestStatusCountSet) =>
Expand Down
4 changes: 2 additions & 2 deletions coral/types/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3167,8 +3167,8 @@ export type operations = {
};
};
responses: {
/** @description default response */
default: {
/** @description OK */
200: {
content: {
"application/json": components["schemas"]["RequestsCountOverview"];
};
Expand Down

0 comments on commit b9d3bde

Please sign in to comment.