Skip to content

Commit

Permalink
PR changes applied
Browse files Browse the repository at this point in the history
  • Loading branch information
cescoferraro committed May 11, 2022
1 parent 7cf4983 commit 2706858
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 20 deletions.
4 changes: 1 addition & 3 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"scripts": {
"start": "craco start",
"build": "craco build",
"test:work": "craco test --watchAll=false --coverage ./src/hooks --collectCoverageFrom='src/hooks/**/*.(tsx|ts)'",
"test:unit": "craco test --watchAll=false --coverage",
"test:integration": "npm run cy:run",
"test:lint": "eslint ./src/**/*.{ts,tsx}",
Expand Down Expand Up @@ -79,8 +78,7 @@
"jest": {
"transformIgnorePatterns": [
"/node_modules/(?!antd|@ant-design|rc-.+?|@babel/runtime).+(js|jsx)$"
],
"testMatch": [ "<rootDir>/src/hooks/**/*.test.tsx" ]
]
},
"resolutions": {
"styled-components": "^5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {renderHook} from '@testing-library/react-hooks';
import {SemanticGroupNames} from '../constants/SemanticGroupNames.constants';
import {useDAGChart} from './useDAGChart';
import {SemanticGroupNames} from '../../constants/SemanticGroupNames.constants';
import {useDAGChart} from '../useDAGChart';

test('useDAGChart with empty span', () => {
const {result} = renderHook(() => useDAGChart({}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {act, renderHook} from '@testing-library/react-hooks';
import {useDoubleClick} from './useDoubleClick';
import {useDoubleClick} from '../useDoubleClick';

test('useDoubleClick', () => {
const doubleClick = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {renderHook} from '@testing-library/react-hooks';
import {useElementSize} from './useElementSize';
import {useElementSize} from '../useElementSize';

test('useElementSize', () => {
const {result} = renderHook(() => useElementSize());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {renderHook} from '@testing-library/react-hooks';
import {GuidedTours} from '../services/GuidedTour.service';
import useGuidedTour from './useGuidedTour';
import {GuidedTours} from '../../services/GuidedTour.service';
import useGuidedTour from '../useGuidedTour';

test('useGuidedTour', () => {
const {result} = renderHook(() => useGuidedTour(GuidedTours.Home));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {renderHook} from '@testing-library/react-hooks';
import usePolling from './usePolling';
import usePolling from '../usePolling';

test('usePolling', async () => {
const callback = jest.fn();
Expand Down
8 changes: 4 additions & 4 deletions web/src/hooks/useDAGChart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import {Dag} from 'd3-dag';
import _ from 'lodash';
import {TSpanMap} from '../components/Diagram/components/DAG';

export const useDAGChart = (
spanMap: TSpanMap = {}
): void | {
interface DAGResponse {
dag: Dag<{id: string; parentIds: string[]}, undefined>;
layout: {width: number; height: number};
} => {
}

export const useDAGChart = (spanMap: TSpanMap = {}): void | DAGResponse => {
if (_.isEmpty(spanMap)) {
return;
}
Expand Down
7 changes: 1 addition & 6 deletions web/src/hooks/usePolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@ import {useEffect} from 'react';

interface usePollingProps {
callback(): void;

delay: number;
isPolling: boolean;
}

const usePolling = ({callback, delay = 1000, isPolling}: usePollingProps): void => {
useEffect(() => {
let interval: any = null;

console.log(1);
interval = setInterval(() => {
console.log(2);
if (isPolling) {
console.log(3);
callback();
} else {
console.log(4);
interval && clearInterval(interval);
}
}, delay);

return () => {
console.log(5);
return interval && clearInterval(interval);
};
}, [delay, isPolling, callback]);
Expand Down

0 comments on commit 2706858

Please sign in to comment.