2026-03-09 19:05:29 +08:00
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
|
import { approvePendingCommentModeration, isPendingApprovalAwaiting, isPendingApprovalRejected, rejectPendingCommentModeration } from '../pending-approval-moderation';
|
|
|
|
|
|
|
|
|
|
describe('pending approval moderation utils', () => {
|
|
|
|
|
it('publishes approval with approved=true', () => {
|
|
|
|
|
expect(approvePendingCommentModeration).toEqual({ approved: true });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('publishes rejection with approved=false and no removed flag', () => {
|
|
|
|
|
expect(rejectPendingCommentModeration).toEqual({ approved: false });
|
|
|
|
|
expect('removed' in rejectPendingCommentModeration).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
2026-04-19 15:02:36 +07:00
|
|
|
it('treats approved=false as rejected for display after pkc removes pendingApproval', () => {
|
2026-03-09 19:05:29 +08:00
|
|
|
expect(isPendingApprovalRejected({ pendingApproval: true, approved: false })).toBe(true);
|
2026-04-19 15:02:36 +07:00
|
|
|
expect(isPendingApprovalRejected({ pendingApproval: false, approved: false })).toBe(true);
|
2026-03-09 19:05:29 +08:00
|
|
|
expect(isPendingApprovalAwaiting({ pendingApproval: true, approved: false })).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('keeps pending approvals awaiting when no decision has been made', () => {
|
|
|
|
|
expect(isPendingApprovalRejected({ pendingApproval: true })).toBe(false);
|
|
|
|
|
expect(isPendingApprovalAwaiting({ pendingApproval: true })).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
});
|