import { IamAccount } from '@api/graphql';
import { Test, TestingModule } from '@nestjs/testing';
import { IamMeAccountHandler } from './iam-me-account.handler';

describe('IamMeAccountHandler', () => {
  let handler: IamMeAccountHandler;

  beforeEach(async () => {
    const module: TestingModule = await Test.createTestingModule({
      providers: [IamMeAccountHandler],
    }).compile();

    handler = module.get(IamMeAccountHandler);
  });

  it('returns the authenticated account it receives, unchanged (no DB read — D1)', async () => {
    const account = {
      id: 'acc-1111',
      email: 'ada@aurora.dev',
      username: 'ada',
      user: { name: 'Ada', surname: 'Lovelace' },
    } as unknown as IamAccount;

    const result = await handler.main(account);

    // Same reference back: the handler surfaces the context account; it does not re-fetch.
    expect(result).toBe(account);
  });
});
