msyavuz commented on code in PR #37580: URL: https://github.com/apache/superset/pull/37580#discussion_r2758115277
########## superset-frontend/plugins/legacy-plugin-chart-world-map/test/WorldMap.test.ts: ########## @@ -0,0 +1,307 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import d3 from 'd3'; +import WorldMap from '../src/WorldMap'; + +// Mock Datamap +const mockBubbles = jest.fn(); +const mockUpdateChoropleth = jest.fn(); +const mockSvg = { + selectAll: jest.fn().mockReturnThis(), + on: jest.fn().mockReturnThis(), + attr: jest.fn().mockReturnThis(), + style: jest.fn().mockReturnThis(), +}; + +jest.mock('datamaps/dist/datamaps.all.min', () => { + return jest.fn().mockImplementation((config) => { + // Call the done callback immediately to simulate Datamap initialization + if (config.done) { + config.done({ + svg: mockSvg, + }); + } + return { + bubbles: mockBubbles, + updateChoropleth: mockUpdateChoropleth, + svg: mockSvg, + }; + }); +}); + +describe('WorldMap hover behavior', () => { Review Comment: Can we flatten this and get rid of the describe block? ########## superset-frontend/plugins/legacy-plugin-chart-world-map/test/tsconfig.json: ########## @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.options.json", + "include": ["**/*"], + "compilerOptions": { + "esModuleInterop": true, + "types": ["jest", "node"] + } +} Review Comment: This shouldn't be necessary, we already have a tsconfig in the plugin's directory ########## superset-frontend/plugins/legacy-plugin-chart-world-map/src/WorldMap.js: ########## @@ -244,7 +244,27 @@ function WorldMap(element, props) { datamap.svg .selectAll('.datamaps-subunit') .on('contextmenu', handleContextMenu) - .on('click', handleClick); + .on('click', handleClick) + .on('mouseover', function onMouseOver() { + if (inContextMenu) { + return; + } + const countryId = d3.select(this).attr('class').split(' ')[1]; + // Store original fill color for restoration + d3.select(this).attr('data-original-fill', d3.select(this).style('fill')); Review Comment: This seems relevant -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
