sean2077_obsidian-dynamic-t.../tests/wallpaper-api-url.test.ts
sean2077 57ca0e101e
fix: preserve settings integrity and compatibility
Migrate custom query credentials to SecretStorage and apply custom parameters at request time. Preserve configuration-order scheduling, transactional reorder rollback, and older Obsidian fallback metadata. Align the production bundle with the official ES2021 target while retaining the frozen size gates.
2026-07-21 15:12:19 +08:00

23 lines
874 B
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { buildWallpaperApiUrl } from "../src/wallpaper-apis/core/url-params";
void test("custom API parameters extend existing queries and preserve fragments", () => {
const result = buildWallpaperApiUrl("https://example.com/images?country=cn#results", {
api_key: "a secret/value",
page: 2,
});
const url = new URL(result);
assert.equal(url.searchParams.get("country"), "cn");
assert.equal(url.searchParams.get("api_key"), "a secret/value");
assert.equal(url.searchParams.get("page"), "2");
assert.equal(url.hash, "#results");
});
void test("an empty parameter set leaves a custom endpoint byte-for-byte unchanged", () => {
const endpoint = "https://example.com/images?country=cn";
assert.equal(buildWallpaperApiUrl(endpoint, {}), endpoint);
});