import {
  userRoles,
  userStatus,
  userListStatusFilter,
  permissionTypes,
  saveType,
  consentType,
} from './userConstants.js';

describe('User Constants', () => {
  describe('saveType object', () => {
    test('is defined', () => {
      expect(saveType).toBeDefined();
      expect(typeof saveType).toBe('object');
    });

    test('has Save property with value 1', () => {
      expect(saveType.Save).toBe(1);
    });

    test('has Update property with value 2', () => {
      expect(saveType.Update).toBe(2);
    });

    test('only has two properties', () => {
      expect(Object.keys(saveType)).toHaveLength(2);
    });

    test('all values are numbers', () => {
      Object.values(saveType).forEach((value) => {
        expect(typeof value).toBe('number');
      });
    });
  });

  describe('consentType object', () => {
    test('is defined', () => {
      expect(consentType).toBeDefined();
      expect(typeof consentType).toBe('object');
    });

    test('has DeleteRole property with value 1', () => {
      expect(consentType.DeleteRole).toBe(1);
    });

    test('has Consent property with value 2', () => {
      expect(consentType.Consent).toBe(2);
    });

    test('only has two properties', () => {
      expect(Object.keys(consentType)).toHaveLength(2);
    });

    test('all values are numbers', () => {
      Object.values(consentType).forEach((value) => {
        expect(typeof value).toBe('number');
      });
    });
  });

  describe('userRoles object', () => {
    test('is defined', () => {
      expect(userRoles).toBeDefined();
      expect(typeof userRoles).toBe('object');
    });

    test('has SuperAdmin with correct structure', () => {
      expect(userRoles.SuperAdmin).toBeDefined();
      expect(userRoles.SuperAdmin.key).toBe('20');
      expect(userRoles.SuperAdmin.value).toBe('Super Admin');
    });

    test('has Admin with correct structure', () => {
      expect(userRoles.Admin).toBeDefined();
      expect(userRoles.Admin.key).toBe('21');
      expect(userRoles.Admin.value).toBe('Admin');
    });

    test('has User with correct structure', () => {
      expect(userRoles.User).toBeDefined();
      expect(userRoles.User.key).toBe('25');
      expect(userRoles.User.value).toBe('User');
    });
  });

  describe('userStatus object', () => {
    test('is defined', () => {
      expect(userStatus).toBeDefined();
      expect(typeof userStatus).toBe('object');
    });

    test('has Active with correct structure', () => {
      expect(userStatus.Active).toBeDefined();
      expect(userStatus.Active.key).toBe('22');
      expect(userStatus.Active.value).toBe('Active');
    });

    test('has Deactive with correct structure', () => {
      expect(userStatus.Deactive).toBeDefined();
      expect(userStatus.Deactive.key).toBe('23');
      expect(userStatus.Deactive.value).toBe('Deactive');
    });

    test('has Deleted with correct structure', () => {
      expect(userStatus.Deleted).toBeDefined();
      expect(userStatus.Deleted.key).toBe('24');
      expect(userStatus.Deleted.value).toBe('Deleted');
    });
  });

  describe('userListStatusFilter array', () => {
    test('is defined and is an array', () => {
      expect(userListStatusFilter).toBeDefined();
      expect(Array.isArray(userListStatusFilter)).toBe(true);
    });

    test('has two elements', () => {
      expect(userListStatusFilter).toHaveLength(2);
    });

    test('first element is All Users', () => {
      expect(userListStatusFilter[0]).toEqual({ key: 1, value: 'All Users' });
    });

    test('second element is Active Users', () => {
      expect(userListStatusFilter[1]).toEqual({ key: 2, value: 'Active Users' });
    });
  });

  describe('permissionTypes array', () => {
    test('is defined and is an array', () => {
      expect(permissionTypes).toBeDefined();
      expect(Array.isArray(permissionTypes)).toBe(true);
    });

    test('has three elements', () => {
      expect(permissionTypes).toHaveLength(3);
    });

    test('first element is Full Access', () => {
      expect(permissionTypes[0]).toEqual({ key: 1, value: 'Full Access' });
    });

    test('second element is Read Only', () => {
      expect(permissionTypes[1]).toEqual({ key: 2, value: 'Read Only' });
    });

    test('third element is No Access', () => {
      expect(permissionTypes[2]).toEqual({ key: 3, value: 'No Access' });
    });

    test('all elements have key and value properties', () => {
      permissionTypes.forEach((permission) => {
        expect(permission).toHaveProperty('key');
        expect(permission).toHaveProperty('value');
        expect(typeof permission.key).toBe('number');
        expect(typeof permission.value).toBe('string');
      });
    });
  });

  describe('Integration tests', () => {
    test('saveType and consentType values are unique', () => {
      const allValues = [...Object.values(saveType), ...Object.values(consentType)];
      expect(allValues).toContain(1);
      expect(allValues).toContain(2);
    });

    test('all exported constants are defined', () => {
      expect(userRoles).toBeDefined();
      expect(userStatus).toBeDefined();
      expect(userListStatusFilter).toBeDefined();
      expect(permissionTypes).toBeDefined();
      expect(saveType).toBeDefined();
      expect(consentType).toBeDefined();
    });
  });
});
