Collapse folders and zips by default

This commit is contained in:
“Naeel”
2026-09-06 12:37:06 +03:00
parent 860cdd4214
commit 8316e19725
3 changed files with 52 additions and 4 deletions
+48
View File
@@ -0,0 +1,48 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { render } from '../upload/frontend/table/render.js';
function elements() {
return { tableBodyEl: { innerHTML: '' }, countEl: { textContent: '' } };
}
function fileNode() {
return {
id: 'file-1',
kind: 'file',
name: 'document.txt',
path: 'folder/document.txt',
file: { size: 7 },
children: [],
expanded: true,
};
}
test('render: папка по умолчанию скрывает дочерние файлы', () => {
const child = fileNode();
const state = {
nodes: [{
id: 'folder-1',
kind: 'folder',
name: 'folder',
path: 'folder',
children: [child],
expanded: false,
}],
};
const output = elements();
render(state, output);
assert.match(output.tableBodyEl.innerHTML, /data-toggle="folder-1"/);
assert.match(output.tableBodyEl.innerHTML, /aria-expanded="false"/);
assert.doesNotMatch(output.tableBodyEl.innerHTML, /data-path="folder\/document\.txt"/);
assert.equal(output.countEl.textContent, '1 файлов · 7 B');
state.nodes[0].expanded = true;
render(state, output);
assert.match(output.tableBodyEl.innerHTML, /data-path="folder\/document\.txt"/);
assert.match(output.tableBodyEl.innerHTML, /aria-expanded="true"/);
});