import type { CustomAttributeValue, PaywallLaunchContext } from '../types';

/**
 * NAM-2544: `null` is a permitted custom-attribute value meaning "attribute not set".
 *
 * This is an executable example of the widened shape and a runtime check that a null
 * attribute round-trips through a PaywallLaunchContext literal. Note: ts-jest runs in
 * transpile-only mode here (tsconfig `isolatedModules: true`), so it does NOT typecheck.
 * The compile-time guard is `npm run build` (tsc), which type-checks the public type
 * against the TurboModule spec at the NamiCampaignManager launch call site — reverting
 * either the type or the spec widening breaks that build.
 */
describe('CustomAttributeValue null support (NAM-2544)', () => {
  it('permits null in a PaywallLaunchContext customAttributes literal', () => {
    const context: PaywallLaunchContext = {
      customAttributes: {
        lastSession: null,
        tier: 'premium',
        isTrial: false,
        seatCount: 3,
      },
    };

    expect(context.customAttributes.lastSession).toBeNull();
    expect(context.customAttributes.tier).toBe('premium');
  });

  it('allows null as a standalone CustomAttributeValue', () => {
    const value: CustomAttributeValue = null;
    expect(value).toBeNull();
  });
});
