This commit is contained in:
26
tests/unit/RendererPerformance.spec.ts
Normal file
26
tests/unit/RendererPerformance.spec.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user