mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
c17d6941be
* chore: migrate to vite plus
* Disable typeAware and typeCheck
* Update CI
* Fix CI
* Fix test
* Clean
* Run test with vp
* Try revert
* react: false In test
* Fix test
* Revert "Try revert"
This reverts commit 009da10473.
* Update
* Update
* Try revert ci changes
* revert
* Run vp migrate
* Disable typeAware and typeCheck for now
* Better resolve for test
* Use vp dev instead of vite
* Update expect
* Fix NormalizeManifestModuleId
* Try increase timeout
* Update to use vp
* Try new check
* Bring back npx vp
* Migrate CI
* Make next-intl resolvable
* Update
* Update
* Update
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { describe, expect, it } from "vite-plus/test";
|
|
|
|
import { appendSearchParamsToUrl } from "../packages/vinext/src/utils/query.js";
|
|
|
|
describe("appendSearchParamsToUrl", () => {
|
|
it("adds query params to a path with no existing query", () => {
|
|
const url = appendSearchParamsToUrl("/search", [["q", "vinext"]]);
|
|
expect(url).toBe("/search?q=vinext");
|
|
});
|
|
|
|
it("preserves existing query params when appending new ones", () => {
|
|
const url = appendSearchParamsToUrl("/search?lang=en", [["q", "vinext"]]);
|
|
expect(url).toBe("/search?lang=en&q=vinext");
|
|
});
|
|
|
|
it("preserves duplicate keys from the existing query string", () => {
|
|
const url = appendSearchParamsToUrl("/search?tag=a&tag=b", [["tag", "c"]]);
|
|
expect(url).toBe("/search?tag=a&tag=b&tag=c");
|
|
});
|
|
|
|
it("preserves hash fragments after appending query params", () => {
|
|
const url = appendSearchParamsToUrl("/search?lang=en#results", [["q", "vinext"]]);
|
|
expect(url).toBe("/search?lang=en&q=vinext#results");
|
|
});
|
|
|
|
it("preserves hashes when the base URL has no existing query string", () => {
|
|
const url = appendSearchParamsToUrl("/search#results", [["q", "vinext"]]);
|
|
expect(url).toBe("/search?q=vinext#results");
|
|
});
|
|
|
|
it("preserves absolute URLs", () => {
|
|
const url = appendSearchParamsToUrl("https://example.com/search?lang=en#results", [
|
|
["q", "vinext"],
|
|
]);
|
|
expect(url).toBe("https://example.com/search?lang=en&q=vinext#results");
|
|
});
|
|
|
|
it("returns the original URL when there are no params to append", () => {
|
|
const url = appendSearchParamsToUrl("/search?lang=en#results", []);
|
|
expect(url).toBe("/search?lang=en#results");
|
|
});
|
|
|
|
it("supports query-only relative URLs", () => {
|
|
const url = appendSearchParamsToUrl("?lang=en", [["q", "vinext"]]);
|
|
expect(url).toBe("?lang=en&q=vinext");
|
|
});
|
|
});
|