import { describe, expect, test } from 'bun:test';
import { syncTemplates } from '../src/tools/sync-templates';
describe('syncTemplates tool', () => {
test('should sync templates from repository or handle network errors', async () => {
const result = await syncTemplates({});
expect(result).toBeDefined();
expect(result.synced_at).toBeDefined();
// Either success or graceful failure due to network issues
if (result.success) {
expect(result.template_count).toBeGreaterThan(0);
expect(result.by_category).toBeDefined();
expect(result.message).toContain('Successfully');
} else {
// Network error is acceptable in test environment
expect(result.message).toContain('failed');
}
}, 120000); // 2 minute timeout for network operations
test('should return result structure', async () => {
const result = await syncTemplates({});
expect(result).toBeDefined();
expect(typeof result.success).toBe('boolean');
expect(typeof result.template_count).toBe('number');
expect(typeof result.by_category).toBe('object');
expect(typeof result.synced_at).toBe('string');
expect(typeof result.message).toBe('string');
}, 120000);
});