| 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | |
| 3 | import { PREVIEW_VIEWPORT_PRESETS, resolvePreviewViewport } from "./previewViewport.ts"; |
| 4 | |
| 5 | describe("previewViewport", () => { |
| 6 | it("resolves fill and exact freeform viewports", () => { |
| 7 | expect(resolvePreviewViewport({ mode: "fill" })).toEqual({ _tag: "fill" }); |
| 8 | expect(resolvePreviewViewport({ mode: "freeform", width: 1024, height: 768 })).toEqual({ |
| 9 | _tag: "freeform", |
| 10 | width: 1024, |
| 11 | height: 768, |
| 12 | }); |
| 13 | }); |
| 14 | |
| 15 | it("resolves device presets in either orientation", () => { |
| 16 | expect(resolvePreviewViewport({ mode: "preset", preset: "iphone-12-pro" })).toEqual({ |
| 17 | _tag: "preset", |
| 18 | width: 390, |
| 19 | height: 844, |
| 20 | presetId: "iphone-12-pro", |
| 21 | }); |
| 22 | expect( |
| 23 | resolvePreviewViewport({ |
| 24 | mode: "preset", |
| 25 | preset: "iphone-12-pro", |
| 26 | orientation: "landscape", |
| 27 | }), |
| 28 | ).toEqual({ |
| 29 | _tag: "preset", |
| 30 | width: 844, |
| 31 | height: 390, |
| 32 | presetId: "iphone-12-pro", |
| 33 | }); |
| 34 | }); |
| 35 | |
| 36 | it("matches Chrome's standard device catalog ordering", () => { |
| 37 | expect(PREVIEW_VIEWPORT_PRESETS.map((preset) => preset.label)).toEqual([ |
| 38 | "iPhone SE", |
| 39 | "iPhone XR", |
| 40 | "iPhone 12 Pro", |
| 41 | "iPhone 14 Pro Max", |
| 42 | "Pixel 7", |
| 43 | "Samsung Galaxy S8+", |
| 44 | "Samsung Galaxy S20 Ultra", |
| 45 | "iPad Mini", |
| 46 | "iPad Air", |
| 47 | "iPad Pro", |
| 48 | "Surface Pro 7", |
| 49 | "Surface Duo", |
| 50 | "Galaxy Z Fold 5", |
| 51 | "Asus Zenbook Fold", |
| 52 | "Samsung Galaxy A51/71", |
| 53 | "Nest Hub", |
| 54 | "Nest Hub Max", |
| 55 | ]); |
| 56 | }); |
| 57 | }); |