fix: вернуть регистрацию activeXHR (onXHR) для отмены загрузки + тесты чистых функций
Deploy drhider / validate (push) Canceled after 0s
Deploy drhider / validate (push) Canceled after 0s
This commit is contained in:
@@ -18,6 +18,10 @@ import { listZipFiles } from './zip/list_zip_files.js';
|
||||
import { parseZip } from './zip/parse_zip.js';
|
||||
import { decodeZipName } from './zip/decode_zip_name.js';
|
||||
import { addFileWithDedup } from './table/add_file_with_dedup.js';
|
||||
import { esc } from './table/esc.js';
|
||||
import { fs } from './table/fs.js';
|
||||
import { fmtSec } from './table/fmt_sec.js';
|
||||
import { estForFile } from './table/est_for_file.js';
|
||||
|
||||
const ALLOWED = ['.pdf', '.doc', '.docx', '.txt', '.md'];
|
||||
|
||||
@@ -194,6 +198,33 @@ function testSuffixes() {
|
||||
console.log(' суффиксы _2/_3: ok');
|
||||
}
|
||||
|
||||
function testEsc() {
|
||||
assert.equal(esc('<a href="x">&\'</a>'), '<a href="x">&'</a>');
|
||||
console.log(' esc (XSS-экранирование): ok');
|
||||
}
|
||||
|
||||
function testFs() {
|
||||
assert.equal(fs(0), '0 B');
|
||||
assert.equal(fs(1023), '1023 B');
|
||||
assert.equal(fs(1024), '1.0 KB');
|
||||
assert.equal(fs(1048576), '1.0 MB');
|
||||
console.log(' fs (размер): ok');
|
||||
}
|
||||
|
||||
function testFmtSec() {
|
||||
assert.equal(fmtSec(0), '0с');
|
||||
assert.equal(fmtSec(59), '59с');
|
||||
assert.equal(fmtSec(60), '1м 0с');
|
||||
assert.equal(fmtSec(125), '2м 5с');
|
||||
console.log(' fmtSec: ok');
|
||||
}
|
||||
|
||||
function testEstForFile() {
|
||||
assert.equal(estForFile({ size: 1048576 }, 12), 12); // 1 МБ × 12 = 12с
|
||||
assert.equal(estForFile(null, 12), 0);
|
||||
console.log(' estForFile: ok');
|
||||
}
|
||||
|
||||
// ── Прогон ──
|
||||
const TESTS = [
|
||||
['decodeZipName', testDecodeZipName],
|
||||
@@ -204,6 +235,10 @@ const TESTS = [
|
||||
['дедуп/суффиксы', testDedup],
|
||||
['лимиты over', testLimits],
|
||||
['суффиксы _2/_3', testSuffixes],
|
||||
['esc XSS', testEsc],
|
||||
['fs размер', testFs],
|
||||
['fmtSec', testFmtSec],
|
||||
['estForFile', testEstForFile],
|
||||
];
|
||||
|
||||
let failed = 0;
|
||||
|
||||
Reference in New Issue
Block a user