Files
frontend-miniapp/tests/unit/RendererPerformance.spec.ts
lyf 9ea1bfab71
Some checks failed
CI / verify (push) Has been cancelled
同步 sgs-frontend-mobile 源码
2026-07-27 11:26:01 +08:00

27 lines
843 B
TypeScript

import { describe, expect, it } from 'vitest'
import { getGuideRendererPixelRatio } from '@/services/performance/rendererPerformance'
describe('rendererPerformance', () => {
it('keeps desktop high-density displays within the desktop cap', () => {
expect(getGuideRendererPixelRatio({ devicePixelRatio: 3, viewportWidth: 1440 }, 1.5)).toBe(1.5)
})
it('uses a lower pixel ratio cap on mobile displays', () => {
expect(getGuideRendererPixelRatio({
devicePixelRatio: 3,
maxTouchPoints: 5,
viewportWidth: 390,
userAgent: 'iPhone'
}, 1.5)).toBe(1.25)
})
it('uses the minimum cap for constrained devices or save-data mode', () => {
expect(getGuideRendererPixelRatio({
devicePixelRatio: 2,
deviceMemory: 2,
hardwareConcurrency: 2,
saveData: true
}, 1.5)).toBe(1)
})
})