mirror of
https://github.com/outline/outline.git
synced 2026-11-21 05:24:03 +03:00
* wip * fix: Treat null expiresAt as no expiry when creating a share * fix: Add bottom padding to share notices
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { addDays, subDays } from "date-fns";
|
|
import { Share } from "@server/models";
|
|
import { buildShare } from "@server/test/factories";
|
|
|
|
describe("Share", () => {
|
|
describe("getPublicSharesForDocumentIds", () => {
|
|
it("should return shares without an expiry or with a future expiry", async () => {
|
|
const noExpiry = await buildShare();
|
|
const future = await buildShare({
|
|
teamId: noExpiry.teamId,
|
|
expiresAt: addDays(new Date(), 1),
|
|
});
|
|
|
|
const shares = await Share.getPublicSharesForDocumentIds(
|
|
noExpiry.teamId,
|
|
[noExpiry.documentId!, future.documentId!]
|
|
);
|
|
|
|
expect(shares.map((share) => share.id).sort()).toEqual(
|
|
[noExpiry.id, future.id].sort()
|
|
);
|
|
});
|
|
|
|
it("should not return expired shares", async () => {
|
|
const share = await buildShare({
|
|
expiresAt: subDays(new Date(), 1),
|
|
});
|
|
|
|
const shares = await Share.getPublicSharesForDocumentIds(
|
|
share.teamId,
|
|
share.documentId!
|
|
);
|
|
|
|
expect(shares).toEqual([]);
|
|
});
|
|
});
|
|
});
|