/**
 * Unit tests for move-draft-to-current helper functions
 */

import { OrgIdMapping, AllOrgMappings } from '../../interfaces/OrgMapping';

// Mock dependencies
jest.mock('../../database/data-source', () => ({
  AppDataSource: {
    createQueryRunner: jest.fn(),
  },
}));

describe('OrgMapping Interfaces', () => {
  describe('OrgIdMapping', () => {
    it('should create a valid OrgIdMapping', () => {
      const mapping: OrgIdMapping = {
        byAncestorDNA: new Map(),
        byDraftId: new Map(),
      };

      expect(mapping.byAncestorDNA).toBeInstanceOf(Map);
      expect(mapping.byDraftId).toBeInstanceOf(Map);
    });

    it('should store and retrieve values correctly', () => {
      const mapping: OrgIdMapping = {
        byAncestorDNA: new Map([['dna1', 'id1']]),
        byDraftId: new Map([['draftId1', 'currentId1']]),
      };

      expect(mapping.byAncestorDNA.get('dna1')).toBe('id1');
      expect(mapping.byDraftId.get('draftId1')).toBe('currentId1');
    });
  });

  describe('AllOrgMappings', () => {
    it('should create a valid AllOrgMappings', () => {
      const mappings: AllOrgMappings = {
        orgRoot: { byAncestorDNA: new Map(), byDraftId: new Map() },
        orgChild1: { byAncestorDNA: new Map(), byDraftId: new Map() },
        orgChild2: { byAncestorDNA: new Map(), byDraftId: new Map() },
        orgChild3: { byAncestorDNA: new Map(), byDraftId: new Map() },
        orgChild4: { byAncestorDNA: new Map(), byDraftId: new Map() },
      };

      expect(mappings.orgRoot).toBeDefined();
      expect(mappings.orgChild1).toBeDefined();
      expect(mappings.orgChild2).toBeDefined();
      expect(mappings.orgChild3).toBeDefined();
      expect(mappings.orgChild4).toBeDefined();
    });
  });
});
