import {
  SocialCallbackDto,
} from '../social.dto';

describe('Social DTOs', () => {
  describe('SocialCallbackDto', () => {
    it('should validate valid social callback data', () => {
      const validData = {
        code: 'auth-code-123',
        state: 'random-state',
      };

      const result = SocialCallbackDto.safeParse(validData);
      expect(result.success).toBe(true);
      if (result.success) {
        expect(result.data).toEqual(validData);
      }
    });

    it('should validate callback data without state', () => {
      const validData = {
        code: 'auth-code-123',
      };

      const result = SocialCallbackDto.safeParse(validData);
      expect(result.success).toBe(true);
      if (result.success) {
        expect(result.data.code).toBe(validData.code);
        expect(result.data.state).toBeUndefined();
      }
    });

    it('should reject empty code', () => {
      const invalidData = {
        code: '',
        state: 'random-state',
      };

      const result = SocialCallbackDto.safeParse(invalidData);
      expect(result.success).toBe(false);
      if (!result.success) {
        expect(result.error.issues[0].path).toContain('code');
      }
    });

    it('should accept any string as code', () => {
      const validData = {
        code: 'any-valid-code-string',
        state: 'optional-state',
      };

      const result = SocialCallbackDto.safeParse(validData);
      expect(result.success).toBe(true);
      if (result.success) {
        expect(result.data.code).toBe(validData.code);
        expect(result.data.state).toBe(validData.state);
      }
    });

    it('should accept any string as state', () => {
      const validData = {
        code: 'auth-code-123',
        state: 'any-state-string',
      };

      const result = SocialCallbackDto.safeParse(validData);
      expect(result.success).toBe(true);
      if (result.success) {
        expect(result.data.state).toBe(validData.state);
      }
    });
  });
});