import assert from 'node:assert/strict'; import test from 'node:test'; import { isPhoneUserAgent, phoneRotation } from './phone-viewport.js'; test('仅手机 UA 在竖屏宽表模式旋转,不影响平板和桌面', () => { for (const ua of ['Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)', 'Mozilla/5.0 (Linux; Android 14) Mobile Safari/537.36']) { assert.equal(isPhoneUserAgent(ua), true); assert.equal(phoneRotation(ua, 390, 844), true); assert.equal(phoneRotation(ua, 844, 390), false); } for (const ua of ['Mozilla/5.0 (iPad; CPU OS 18_0 like Mac OS X)', 'Mozilla/5.0 (Macintosh; Intel Mac OS X)', 'Mozilla/5.0 (Linux; Android 14) Safari/537.36', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)']) { assert.equal(phoneRotation(ua, 390, 844), false); } });