Consolidate MangaCircus app, scraper, and Compose baseline
This commit is contained in:
1 parent
cfb2d79103
commit
eef4ffa07c
103 files changed
+9316
-172
No files matched your search
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
const test = require('node:test'), assert = require('node:assert/strict');
|
||||
const fs = require('node:fs'), path = require('node:path'), vm = require('node:vm');
|
||||
const crypto = require('node:crypto');
|
||||
const source = fs.readFileSync(path.join(__dirname, '../public/collections.js'), 'utf8').split('(async () => {')[0];
|
||||
test('Collection IDs use the native secure-context API when available', () => {
|
||||
const context = { crypto: { randomUUID: () => 'native-uuid' } };
|
||||
vm.runInNewContext(source, context);
|
||||
assert.equal(context.collectionId(), 'native-uuid');
|
||||
});
|
||||
test('Collection IDs work on HTTP without randomUUID and remain unique valid UUIDs', () => {
|
||||
const context = { crypto: { getRandomValues: values => crypto.randomFillSync(values) } };
|
||||
vm.runInNewContext(source, context);
|
||||
const ids = Array.from({ length: 200 }, () => context.collectionId());
|
||||
assert.equal(new Set(ids).size, ids.length);
|
||||
for (const id of ids) assert.match(id, /^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/);
|
||||
});
|
||||
Reference in new issue
Block a user