Skip to content

Commit

Permalink
test: fix mock values for SVG nodes and transformations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo Campos committed May 21, 2024
1 parent b9b2b4f commit 4e01f54
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 1 addition & 3 deletions frontend/src/__test__/screens/Opening.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ const state = {
}
};

vi
.spyOn(redux, 'useSelector')
vi.spyOn(redux, 'useSelector')
.mockImplementation((callback) => callback(state));

describe('Opening screen test cases', () => {
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/OpeningsTab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const OpeningsTab: React.FC<Props> = ({showSpatial, setShowSpatial}) => {
}, []);

useEffect(() => {
console.log(`Loading OpeningsTab components! showSpatial=${showSpatial}`);
//
}, [loadId, openingPolygonNotFound]);

const toggleSpatial = () => {
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/map-services/BcGwWfsApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -168,8 +166,6 @@ export const getOpeningsPolygonFromWfs = async (openingId: number | null): Promi
};

export const getInitialLayers = async (): Promise<MapLayer | null> => {
console.log('API: Fetching initial layer');

let uri = 'https://openmaps.gov.bc.ca/geo/ows';
// service
uri += '?service=WFS';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/screens/Opening/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Opening: React.FC = () => {
const [showSpatial, setShowSpatial] = useState<boolean>(false);

useEffect(() => {
console.log(`showSpatial changed=${showSpatial}`);
//
}, [showSpatial]);

return (
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down

0 comments on commit 4e01f54

Please sign in to comment.