mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-27 16:26:16 +08:00
fix(test): move orphaned test into describe block
Move "clears loading flag when all mutations idle" test inside
the describe("useProviderActions") block for proper test isolation.
This commit is contained in:
@@ -205,7 +205,9 @@ export const codexAdapter: CommonConfigAdapter<string, string> = {
|
||||
}
|
||||
const error = validateTomlFormat(snippet);
|
||||
if (error) {
|
||||
return t("codexConfig.tomlFormatError", { defaultValue: "TOML 格式错误" });
|
||||
return t("codexConfig.tomlFormatError", {
|
||||
defaultValue: "TOML 格式错误",
|
||||
});
|
||||
}
|
||||
return "";
|
||||
},
|
||||
@@ -214,11 +216,7 @@ export const codexAdapter: CommonConfigAdapter<string, string> = {
|
||||
return extractConfigToml(input);
|
||||
},
|
||||
|
||||
computeFinal: (
|
||||
custom: string,
|
||||
common: string,
|
||||
enabled: boolean,
|
||||
): string => {
|
||||
computeFinal: (custom: string, common: string, enabled: boolean): string => {
|
||||
if (!enabled || !hasTomlContent(common)) {
|
||||
return custom;
|
||||
}
|
||||
@@ -274,9 +272,7 @@ export function createGeminiAdapter(
|
||||
defaultSnippet: GEMINI_DEFAULT_SNIPPET,
|
||||
legacyStorageKey: GEMINI_LEGACY_STORAGE_KEY,
|
||||
|
||||
parseSnippet: (
|
||||
snippet: string,
|
||||
): ParseResult<Record<string, string>> => {
|
||||
parseSnippet: (snippet: string): ParseResult<Record<string, string>> => {
|
||||
const result = parseGeminiCommonConfigSnippet(snippet, {
|
||||
strictForbiddenKeys: true,
|
||||
});
|
||||
|
||||
@@ -176,7 +176,10 @@ export function useCommonConfigBase<TConfig, TFinal>({
|
||||
initialData,
|
||||
selectedPresetId,
|
||||
enabled = true,
|
||||
}: UseCommonConfigBaseProps<TConfig, TFinal>): UseCommonConfigBaseReturn<TFinal> {
|
||||
}: UseCommonConfigBaseProps<
|
||||
TConfig,
|
||||
TFinal
|
||||
>): UseCommonConfigBaseReturn<TFinal> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
// ============================================================================
|
||||
|
||||
@@ -450,17 +450,18 @@ describe("useProviderActions", () => {
|
||||
|
||||
expect(result.current.isLoading).toBe(true);
|
||||
});
|
||||
});
|
||||
it("clears loading flag when all mutations idle", () => {
|
||||
addProviderMutation.isPending = false;
|
||||
updateProviderMutation.isPending = false;
|
||||
deleteProviderMutation.isPending = false;
|
||||
switchProviderMutation.isPending = false;
|
||||
|
||||
const { wrapper } = createWrapper();
|
||||
const { result } = renderHook(() => useProviderActions("claude"), {
|
||||
wrapper,
|
||||
it("clears loading flag when all mutations idle", () => {
|
||||
addProviderMutation.isPending = false;
|
||||
updateProviderMutation.isPending = false;
|
||||
deleteProviderMutation.isPending = false;
|
||||
switchProviderMutation.isPending = false;
|
||||
|
||||
const { wrapper } = createWrapper();
|
||||
const { result } = renderHook(() => useProviderActions("claude"), {
|
||||
wrapper,
|
||||
});
|
||||
|
||||
expect(result.current.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
expect(result.current.isLoading).toBe(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user