Skip to content

Commit

Permalink
chore: refactor updateConnectorStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
illfixit committed Aug 27, 2024
1 parent ad9ac95 commit a7e76d3
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
ProvidedConnectorOverviewEntryDto,
ProvidedConnectorOverviewResult,
} from '@sovity.de/authority-portal-client';
import {Patcher, patchObj} from 'src/app/core/utils/object-utils';
import {fakeEnv} from './fake-environments';
import {TEST_ORGANIZATIONS} from './fake-organizations';
import {getUserInfo} from './fake-users';
Expand Down Expand Up @@ -435,18 +436,21 @@ const generateRandomId = (organizationId: string): string => {
}
};

const updateConnector = (
connectorId: string,
patcher: Patcher<ConnectorDetailDto> = () => ({}),
): void => {
TEST_CONNECTORS = TEST_CONNECTORS.map((it) =>
it.connectorId === connectorId ? patchObj(it, patcher) : it,
);
};

const updateConnectorStatus = (
connectorId: string,
status: ConnectorStatusDto = 'ONLINE',
timeout = 5000,
timeout: number = 5000,
): void => {
setTimeout(() => {
const connector = TEST_CONNECTORS.find(
(c) => c.connectorId === connectorId,
);
if (connector) {
console.log('updateConnectorStatus', connectorId, status);
connector.status = status;
}
updateConnector(connectorId, () => ({status}));
}, timeout);
};

0 comments on commit a7e76d3

Please sign in to comment.