Docker-ready Next.js + Prisma/Postgres e-invitation app: themed invite pages, RSVP, comments, share links, email + SMS invites with reply-to-RSVP-by-text, co-hosts, photo dropbox, and browser push notifications.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { isPhotoUploadOpen } from '@/lib/photoWindow';
|
|
|
|
const base = {
|
|
eventDate: new Date('2027-06-01T18:00:00'),
|
|
photosEnabled: true,
|
|
photosClosed: false,
|
|
photoCloseDate: null as Date | null,
|
|
};
|
|
|
|
describe('isPhotoUploadOpen', () => {
|
|
it('is closed before the event starts', () => {
|
|
const now = new Date('2027-06-01T10:00:00');
|
|
expect(isPhotoUploadOpen(base, now)).toBe(false);
|
|
});
|
|
|
|
it('is open once the event has started with no close date', () => {
|
|
const now = new Date('2027-06-01T19:00:00');
|
|
expect(isPhotoUploadOpen(base, now)).toBe(true);
|
|
});
|
|
|
|
it('is closed if the feature is disabled', () => {
|
|
const now = new Date('2027-06-01T19:00:00');
|
|
expect(isPhotoUploadOpen({ ...base, photosEnabled: false }, now)).toBe(false);
|
|
});
|
|
|
|
it('is closed if force-closed, even mid-window', () => {
|
|
const now = new Date('2027-06-01T19:00:00');
|
|
expect(isPhotoUploadOpen({ ...base, photosClosed: true }, now)).toBe(false);
|
|
});
|
|
|
|
it('is open before the close date', () => {
|
|
const now = new Date('2027-06-02T10:00:00');
|
|
const closeDate = new Date('2027-06-03T00:00:00');
|
|
expect(isPhotoUploadOpen({ ...base, photoCloseDate: closeDate }, now)).toBe(true);
|
|
});
|
|
|
|
it('is closed after the close date', () => {
|
|
const now = new Date('2027-06-04T10:00:00');
|
|
const closeDate = new Date('2027-06-03T00:00:00');
|
|
expect(isPhotoUploadOpen({ ...base, photoCloseDate: closeDate }, now)).toBe(false);
|
|
});
|
|
});
|