27 lines
843 B
TypeScript
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)
|
|
})
|
|
})
|