From 4e01f5438971ec51187d22b7bc0ca1ffe5db9bb0 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Tue, 21 May 2024 10:45:44 -0300 Subject: [PATCH] test: fix mock values for SVG nodes and transformations --- frontend/src/__test__/screens/Opening.test.tsx | 4 +--- frontend/src/components/OpeningsTab/index.tsx | 2 +- frontend/src/map-services/BcGwWfsApi.tsx | 4 ---- frontend/src/screens/Opening/index.tsx | 2 +- frontend/src/setupTests.ts | 11 ++++++++++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/__test__/screens/Opening.test.tsx b/frontend/src/__test__/screens/Opening.test.tsx index 7b2e6981..85fa1691 100644 --- a/frontend/src/__test__/screens/Opening.test.tsx +++ b/frontend/src/__test__/screens/Opening.test.tsx @@ -12,8 +12,7 @@ const state = { } }; -vi - .spyOn(redux, 'useSelector') +vi.spyOn(redux, 'useSelector') .mockImplementation((callback) => callback(state)); describe('Opening screen test cases', () => { @@ -26,7 +25,6 @@ describe('Opening screen test cases', () => { const pageTitleComp = getByTestId('opening-pagetitle'); expect(pageTitleComp).toBeDefined(); - //expect(pageTitleComp).toHaveTextContent('Create, manage or check opening information'); //const subtitle = 'Create, manage or check opening information'; //expect(screen.getByText(subtitle)).toBeDefined(); diff --git a/frontend/src/components/OpeningsTab/index.tsx b/frontend/src/components/OpeningsTab/index.tsx index f3984a07..b0591e97 100644 --- a/frontend/src/components/OpeningsTab/index.tsx +++ b/frontend/src/components/OpeningsTab/index.tsx @@ -40,7 +40,7 @@ const OpeningsTab: React.FC = ({showSpatial, setShowSpatial}) => { }, []); useEffect(() => { - console.log(`Loading OpeningsTab components! showSpatial=${showSpatial}`); + // }, [loadId, openingPolygonNotFound]); const toggleSpatial = () => { diff --git a/frontend/src/map-services/BcGwWfsApi.tsx b/frontend/src/map-services/BcGwWfsApi.tsx index 7923c3eb..3446e882 100644 --- a/frontend/src/map-services/BcGwWfsApi.tsx +++ b/frontend/src/map-services/BcGwWfsApi.tsx @@ -107,8 +107,6 @@ export const getOpeningsPolygonFromWfs = async (openingId: number | null): Promi return Promise.resolve(null); } - console.log(`API: Fetch using opening ids=${JSON.stringify(openingId)}`); - // NEXT STEPS: // - Work with dynamic properties // - Work with different SRS !? (to be discussed) @@ -168,8 +166,6 @@ export const getOpeningsPolygonFromWfs = async (openingId: number | null): Promi }; export const getInitialLayers = async (): Promise => { - console.log('API: Fetching initial layer'); - let uri = 'https://openmaps.gov.bc.ca/geo/ows'; // service uri += '?service=WFS'; diff --git a/frontend/src/screens/Opening/index.tsx b/frontend/src/screens/Opening/index.tsx index 7efee481..883acd4f 100644 --- a/frontend/src/screens/Opening/index.tsx +++ b/frontend/src/screens/Opening/index.tsx @@ -14,7 +14,7 @@ const Opening: React.FC = () => { const [showSpatial, setShowSpatial] = useState(false); useEffect(() => { - console.log(`showSpatial changed=${showSpatial}`); + // }, [showSpatial]); return ( diff --git a/frontend/src/setupTests.ts b/frontend/src/setupTests.ts index 5f82a3a3..ef3e1633 100644 --- a/frontend/src/setupTests.ts +++ b/frontend/src/setupTests.ts @@ -43,7 +43,16 @@ Object.defineProperty(global.SVGElement.prototype, 'getBBox', { Object.defineProperty(global.SVGElement.prototype, 'getComputedTextLength', { writable: true, - value: vi.fn().mockReturnValue(0), + value: vi.fn().mockReturnValue(220), +}); + +Object.defineProperty(global.SVGElement.prototype, 'transform', { + writable: true, + value: { + baseVal: { + consolidate: vi.fn(() => {}) + }, + } }); Object.defineProperty(global.SVGElement.prototype, 'createSVGMatrix', {