import { describe, it, expect, vi, beforeEach } from 'vitest';
import { storageService } from './storageService';

describe('storageService', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  describe('listFiles', () => {
    it('should return list of files', async () => {
      const files = await storageService.listFiles();

      expect(files).toBeDefined();
      expect(Array.isArray(files)).toBe(true);
      expect(files.length).toBeGreaterThan(0);
      expect(files[0]).toHaveProperty('id');
      expect(files[0]).toHaveProperty('name');
      expect(files[0]).toHaveProperty('type');
    });

    it('should list files in specific folder', async () => {
      const files = await storageService.listFiles('folder-1');

      expect(files).toBeDefined();
      expect(Array.isArray(files)).toBe(true);
    });
  });

  describe('getFile', () => {
    it('should return file details', async () => {
      const file = await storageService.getFile('1');

      expect(file).toBeDefined();
      expect(file).toHaveProperty('id');
      expect(file).toHaveProperty('name');
    });
  });

  describe('deleteFiles', () => {
    it('should delete files', async () => {
      const result = await storageService.deleteFiles(['1', '2']);

      expect(result).toBeDefined();
      expect(result.success).toBe(true);
    });
  });

  describe('moveFiles', () => {
    it('should move files to target folder', async () => {
      const result = await storageService.moveFiles(
        ['1', '2'],
        'target-folder',
      );

      expect(result).toBeDefined();
      expect(result.success).toBe(true);
    });
  });
});
