源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
|
||||
import { getInitialIsMobile } from "../src/hooks/use-mobile";
|
||||
|
||||
describe("getInitialIsMobile", () => {
|
||||
test("reads the mobile media query synchronously", () => {
|
||||
let receivedQuery = "";
|
||||
|
||||
const isMobile = getInitialIsMobile((query) => {
|
||||
receivedQuery = query;
|
||||
return { matches: true };
|
||||
});
|
||||
|
||||
expect(receivedQuery).toBe("(max-width: 1023px)");
|
||||
expect(isMobile).toBe(true);
|
||||
});
|
||||
|
||||
test("defaults to desktop without window matchMedia", () => {
|
||||
expect(getInitialIsMobile()).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user