michael-s-molina commented on a change in pull request #13719: URL: https://github.com/apache/superset/pull/13719#discussion_r600502893
########## File path: superset-frontend/src/explore/exploreUtils/exploreChart.test.ts ########## @@ -0,0 +1,44 @@ +/** + * 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 { exploreChart } from '.'; + +/** + * I'm leaving this comment here to show one of the approaches I tried and it didn't work. + * + * The same problem occurred with: "exploreChart" + */ +// import * as index from './index'; +// const spy = jest.spyOn(index, 'postForm'); + +const params = { + formData: { data: 'same-string' }, + resultFormat: 'json', + resultType: 'full', + force: false, +}; + +/** + * For some reason the spy is not working properly and I also did not find a way to mock only the "postForm" + * I believe that if this file is divided the problem will be solved. + */ +test.skip('Should call postForm correctly', () => { Review comment: `exploreChart` is just calling `getExploreUrl` and `postForm`. I don't think is necessary to create a test for `exploreChart`. Just testing `getExploreUrl` and `postForm` is enough. ########## File path: superset-frontend/src/explore/exploreUtils/index.js ########## @@ -236,6 +241,9 @@ export const buildV1ChartDataPayload = ({ export const getLegacyEndpointType = ({ resultType, resultFormat }) => resultFormat === 'csv' ? resultFormat : resultType; +/** Review comment: One way to test `postForm` is to mock `document.createElement` returning an object that contains a monitored `submit` function. Then we can test if all the required fields (action, method, token, data) are correctly configured when submitting. We can also test that the form is added hidden and removed after submit. -- 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. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
