const { test } = require('node:test'); const assert = require('node:assert/strict'); const { normalize, rotation, coordinates } = require('./fullscreen-orientation'); test('orientation defaults and only rotates mismatched viewports', () => { assert.equal(normalize('invalid'), 'auto'); assert.equal(rotation('auto', 390, 844), 0); assert.equal(rotation('landscape', 390, 844), 90); assert.equal(rotation('landscape', 844, 390), 0); assert.equal(rotation('portrait', 844, 390), -90); }); test('rotated touch coordinates preserve local seek and swipe axes', () => { const rect = { left: 10, top: 20, right: 400, bottom: 864, width: 390, height: 844 }; assert.deepEqual(coordinates(400, 20, rect, 90), { x: 0, y: 0, width: 844, height: 390 }); assert.deepEqual(coordinates(10, 864, rect, 90), { x: 844, y: 390, width: 844, height: 390 }); assert.deepEqual(coordinates(10, 864, rect, -90), { x: 0, y: 0, width: 844, height: 390 }); assert.deepEqual(coordinates(205, 442, rect), { x: 195, y: 422, width: 390, height: 844 }); });