mirror of
https://github.com/osnr/TabFS.git
synced 2024-05-09 17:16:35 +02:00
be519afe5f
Introduces a 'named variable' syntax so we can remove all the manual indexing into path components / converting to int in individual fs ops. Also rewrites the route finding to use regex: all routes are compiled to regexes, then the route finder just walks through them all until it hits a match. Doesn't fully work yet; JS test passes.
22 lines
797 B
JavaScript
22 lines
797 B
JavaScript
const assert = require('assert');
|
|
|
|
// mock chrome namespace
|
|
global.chrome = {};
|
|
// run background.js
|
|
const {router, findRoute} = require('../extension/background');
|
|
|
|
(async () => {
|
|
const tabRoute = await router['/tabs/by-id/#TAB_ID'].readdir();
|
|
assert(['.', '..', 'url.txt', 'title.txt', 'text.txt']
|
|
.every(file => tabRoute.entries.includes(file)));
|
|
|
|
assert.deepEqual(await router['/'].readdir(),
|
|
{ entries: ['.', '..', 'windows', 'extensions', 'tabs', 'runtime'] });
|
|
assert.deepEqual(await router['/tabs'].readdir(),
|
|
{ entries: ['.', '..', 'create',
|
|
'by-id', 'by-title', 'last-focused'] });
|
|
|
|
assert.deepEqual(findRoute('/tabs/by-id/10/url.txt'),
|
|
router['/tabs/by-id/#TAB_ID/url.txt']);
|
|
})();
|