import assert from 'node:assert/strict'; import test from 'node:test'; import { isPreviewMediaPath, partitionSceneMediaDrops, sceneTitleFromMediaPath, } from './fileDrop'; void test('sceneTitleFromMediaPath strips extension and path', () => { assert.equal(sceneTitleFromMediaPath('C:\\media\\Forest Gate.png'), 'Forest Gate'); assert.equal(sceneTitleFromMediaPath('/tmp/battle.mp4'), 'battle'); assert.equal(sceneTitleFromMediaPath('onlyname'), 'onlyname'); }); void test('isPreviewMediaPath accepts images and videos', () => { assert.equal(isPreviewMediaPath('a.png'), true); assert.equal(isPreviewMediaPath('a.JPG'), true); assert.equal(isPreviewMediaPath('a.webm'), true); assert.equal(isPreviewMediaPath('a.mp3'), false); assert.equal(isPreviewMediaPath('a.pdf'), false); }); void test('partitionSceneMediaDrops keeps valid and rejects others', () => { const { accepted, rejected } = partitionSceneMediaDrops([ { path: 'D:\\a\\one.jpg', name: 'one.jpg' }, { path: 'D:\\a\\two.mp3', name: 'two.mp3' }, { path: '', name: 'ghost.png' }, { path: 'D:\\a\\three.mov', name: 'three.mov' }, ]); assert.deepEqual( accepted.map((x) => x.name), ['one.jpg', 'three.mov'], ); assert.deepEqual(rejected, [ { name: 'two.mp3', reason: 'unsupported' }, { name: 'ghost.png', reason: 'no_path' }, ]); });