import { adminSessionCookieName } from './admin-session-cookie';

describe('adminSessionCookieName', () => {
  const originalNodeEnv = process.env['NODE_ENV'];

  afterEach(() => {
    if (originalNodeEnv === undefined) {
      delete process.env['NODE_ENV'];
    } else {
      process.env['NODE_ENV'] = originalNodeEnv;
    }
  });

  it('uses the `__Host-` prefixed name in production', () => {
    process.env['NODE_ENV'] = 'production';
    expect(adminSessionCookieName()).toBe('__Host-portal_admin_session');
  });

  it('uses the unprefixed name in development', () => {
    process.env['NODE_ENV'] = 'development';
    expect(adminSessionCookieName()).toBe('portal_admin_session');
  });

  it('defaults to development naming when NODE_ENV is unset', () => {
    delete process.env['NODE_ENV'];
    expect(adminSessionCookieName()).toBe('portal_admin_session');
  });
});
