Files
RedditBot/tests/media-sync-auth.test.ts

24 lines
801 B
TypeScript

import { describe, expect, it, vi } from 'vitest';
import { MediaSyncService } from '../src/services/media-sync.js';
import { createMockLogger } from './mockLogger.js';
describe('MediaSyncService account authentication gate', () => {
it('does not touch chat while the global account context is unauthenticated', async () => {
const chat = {
refreshTopChats: vi.fn(),
fetchAllMessages: vi.fn(),
};
const auth = { isFullyAuthenticated: vi.fn(() => false) };
const service = new MediaSyncService(
chat as never,
createMockLogger(),
30 * 60 * 1000,
auth,
);
await expect(service.triggerSync()).resolves.toBe(false);
expect(chat.refreshTopChats).not.toHaveBeenCalled();
expect(chat.fetchAllMessages).not.toHaveBeenCalled();
});
});