Copilot commented on code in PR #720: URL: https://github.com/apache/shenyu-dashboard/pull/720#discussion_r4321064330
########## src/routes/Document/ApiDoc.test.js: ########## @@ -0,0 +1,174 @@ +/* + * 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 React from "react"; +import { fireEvent, render, screen, waitFor } from "@testing-library/react"; +import { + fetchShenYuDictByType, + getApiDetail, + getApiMockRequest, +} from "../../services/api"; +import ApiDoc from "./ApiDoc"; + +jest.mock("../../services/api", () => ({ + fetchShenYuDictByType: jest.fn(), + getApiDetail: jest.fn(), + getApiMockRequest: jest.fn(), +})); Review Comment: This mock replaces the entire `../../services/api` module with only three exports. Since `ApiDoc` imports additional named exports from the same module, they will become `undefined` in this test environment, making the tests fragile if the component starts invoking those code paths (or if the component changes to call additional service functions during render/effects). Prefer a partial mock that spreads `jest.requireActual('../../services/api')` and overrides only the functions under test. -- 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]
