Files
glassMxrph/tests/launcher.test.cjs
T
mxandClaude Opus 5.5 99e64a7713 Add glassMxrph shell sources
Initial commit of the Quickshell desktop suite: bar, dock, launcher,
settings, Control Center, dashboard, OSD, lock screen, desktop widgets,
plugin host with the vendored Noctalia/Omarchy compatibility layer,
helpers, packaging, tests and phase documentation.

Includes the optimization work so far: usage widgets and dashboard
gauges no longer animate continuously, desktop widgets pause while
covered, system controls stop flickering on background polls, dock app
matching uses an indexed catalog, and workspace ghosts are created only
for occupied slots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:36:17 +02:00

19 lines
1.4 KiB
JavaScript

const fs=require('node:fs'),vm=require('node:vm'),path=require('node:path'),assert=require('node:assert/strict');
const root=path.join(__dirname,'..'),search=vm.createContext({});
vm.runInContext(fs.readFileSync(path.join(root,'quickshell/launcher/SearchLogic.js'),'utf8'),search);
const items=[
{id:'edit',title:'Editor',fields:[{text:'Editor'},{text:'Text development',penalty:200}]},
{id:'edit-plus',title:'Editor Plus',fields:[{text:'Editor Plus'}]},
{id:'photo',title:'Éditeur photo',fields:[{text:'Éditeur photo'}]},
{id:'web',title:'Web Browser',fields:[{text:'Web Browser'},{text:'Internet',penalty:200}]}
];
const index=search.index(items),results=(q,n=50)=>search.rank(index,q,n);
assert.equal(results('editor')[0].id,'edit');assert.equal(results('edtr')[0].id,'edit');
assert.equal(results('EDITEUR')[0].id,'photo');assert.equal(results('web bro')[0].id,'web');
assert.equal(results('internet')[0].id,'web');assert.equal(results('text editor')[0].id,'edit');
assert.equal(results('doesnotexist').length,0);assert.equal(results('; rm -rf /').length,0);
assert.equal(results('',2).length,2);assert.equal(results(' ').length,4);
assert.equal(results('editor impossible').length,0);
assert.equal(items[0].title,'Editor');assert(search.score('dock','dock')>search.score('docker','dock'));
console.log('Launcher ranking: exact/prefix/fuzzy, accents/case, keywords, multi-token, limits and no-match tests passed.');