| 1 | import { expect, it } from "vite-plus/test"; |
| 2 | import { resolveDeviceShape } from "./shapeProfile.ts"; |
| 3 | |
| 4 | it("chooses tablet and phone families without mistaking display rotation for device shape", () => { |
| 5 | expect( |
| 6 | resolveDeviceShape({ platform: "ios", name: "iPad Pro 11-inch (M5)", portraitAspect: 0.75 }).id, |
| 7 | ).toBe("ios-tablet"); |
| 8 | expect( |
| 9 | resolveDeviceShape({ platform: "ios", name: "iPhone 18 Pro", portraitAspect: 0.46 }).id, |
| 10 | ).toBe("ios-phone"); |
| 11 | expect( |
| 12 | resolveDeviceShape({ platform: "android", name: "Pixel 9", portraitAspect: 0.45 }).id, |
| 13 | ).toBe("android-phone"); |
| 14 | expect( |
| 15 | resolveDeviceShape({ platform: "android", name: "Pixel Tablet", portraitAspect: 0.625 }).id, |
| 16 | ).toBe("android-tablet"); |
| 17 | }); |
| 18 | |
| 19 | it("uses the screen shape for renamed devices and a phone fallback before metadata arrives", () => { |
| 20 | expect(resolveDeviceShape({ platform: "ios", name: "Julius", portraitAspect: 0.75 }).id).toBe( |
| 21 | "ios-tablet", |
| 22 | ); |
| 23 | expect(resolveDeviceShape({ platform: "android", portraitAspect: 0.45 }).id).toBe( |
| 24 | "android-phone", |
| 25 | ); |
| 26 | expect(resolveDeviceShape({ platform: "ios", portraitAspect: Number.NaN }).id).toBe("ios-phone"); |
| 27 | }); |