first commit
This commit is contained in:
commit
b54624be96
226 files changed
+108840
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { isOnOrBeforeVisibleDate, throughVisibleDate } from '../visibility.ts';
|
||||
|
||||
describe('throughVisibleDate', () => {
|
||||
const rows = [{ date: '2026-09-05' }, { date: '2026-09-06' }, { date: '2026-09-07' }];
|
||||
|
||||
it('drops rows after the publish cutoff', () => {
|
||||
expect(throughVisibleDate(rows, '2026-09-06')).toEqual([
|
||||
{ date: '2026-09-05' },
|
||||
{ date: '2026-09-06' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns all rows when cutoff is missing', () => {
|
||||
expect(throughVisibleDate(rows, undefined)).toEqual(rows);
|
||||
expect(throughVisibleDate(rows, null)).toEqual(rows);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isOnOrBeforeVisibleDate', () => {
|
||||
it('rejects dates after the cutoff', () => {
|
||||
expect(isOnOrBeforeVisibleDate('2026-09-07', '2026-09-06')).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts dates on or before the cutoff', () => {
|
||||
expect(isOnOrBeforeVisibleDate('2026-09-06', '2026-09-06')).toBe(true);
|
||||
expect(isOnOrBeforeVisibleDate('2026-09-05', '2026-09-06')).toBe(true);
|
||||
});
|
||||
|
||||
it('rejects empty dates', () => {
|
||||
expect(isOnOrBeforeVisibleDate(null, '2026-09-06')).toBe(false);
|
||||
expect(isOnOrBeforeVisibleDate(undefined, '2026-09-06')).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user