Files
outline/server/models/helpers/AttachmentHelper.test.ts
Tom Moor a3b2615edf chore: Remove future public bucket usage (#10977)
* No longer upload avatars to public bucket

* Public redirect

* tests

* test

* test
2025-12-24 20:24:58 -05:00

38 lines
971 B
TypeScript

import AttachmentHelper from "./AttachmentHelper";
describe("AttachmentHelper", () => {
describe("getKey", () => {
it("should return the correct key for a private attachment", () => {
const key = AttachmentHelper.getKey({
id: "123",
name: "test.png",
userId: "456",
});
expect(key).toEqual("uploads/456/123/test.png");
});
it("should return the correct key for a long file name", () => {
const key = AttachmentHelper.getKey({
id: "123",
name: "a".repeat(300),
userId: "456",
});
expect(key).toEqual(
`uploads/456/123/${"a".repeat(AttachmentHelper.maximumFileNameLength)}`
);
});
it("should remove invalid characters from the key", () => {
const key = AttachmentHelper.getKey({
id: "123",
name: "test/../one.png",
userId: "456",
});
expect(key).toEqual("uploads/456/123/test/one.png");
});
});
});