chore: import ovis-composer into repo with baseline tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
edf09cf532
commit
c05e252d79
21 files changed
+4312
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { LIMITS, validate, validateMany, mention, removeMention } from "../mod/ovis-composer/attachments.js";
|
||||
|
||||
test("validate rejects over 32 MiB", () => {
|
||||
const r = validate({ bytes: 33 * 2 ** 20 });
|
||||
assert.equal(r.ok, false);
|
||||
assert.equal(r.reason, "Plik przekracza limit 32 MiB");
|
||||
});
|
||||
|
||||
test("validate accepts a normal file and an image", () => {
|
||||
assert.deepEqual(validate({ name: "a.txt", bytes: 10 }), { ok: true });
|
||||
assert.deepEqual(validate({ name: "a.png", bytes: 10 }), { ok: true });
|
||||
});
|
||||
|
||||
test("validate rejects junk and unknown kind", () => {
|
||||
assert.equal(validate(null).ok, false);
|
||||
assert.equal(validate({ bytes: NaN }).ok, false);
|
||||
assert.equal(validate({ kind: "video", bytes: 1 }).ok, false);
|
||||
});
|
||||
|
||||
test("validateMany enforces count limit", () => {
|
||||
assert.equal(LIMITS.filesPerAction, 100);
|
||||
const files = Array.from({ length: 101 }, () => ({ name: "a", bytes: 1 }));
|
||||
assert.equal(validateMany(files).ok, false);
|
||||
assert.equal(validateMany(files.slice(0, 100)).ok, true);
|
||||
});
|
||||
|
||||
test("mention", () => {
|
||||
assert.equal(mention(" /a/b "), "@/a/b");
|
||||
assert.equal(mention(""), "");
|
||||
assert.equal(mention(5), "");
|
||||
});
|
||||
|
||||
test("removeMention removes only the standalone token", () => {
|
||||
assert.equal(removeMention("see @src/a.rs now", "src/a.rs"), "see now");
|
||||
assert.equal(removeMention("see @src/a.rsx now", "src/a.rs"), "see @src/a.rsx now");
|
||||
});
|
||||
Reference in new issue
Block a user