import {
  clearanceSettingCode,
  clearanceOutputSettingCode,
} from './clearance.util';

describe('clearance.util — clearanceSettingCode', () => {
  it('resolves import container with/without customs', () => {
    expect(clearanceSettingCode('IMPORT', 'CONTAINER', true)).toBe(
      'clearance_import_container_with_customs',
    );
    expect(clearanceSettingCode('IMPORT', 'CONTAINER', false)).toBe(
      'clearance_import_container_without_customs',
    );
  });

  it('resolves export bulk with/without customs', () => {
    expect(clearanceSettingCode('EXPORT', 'BULK', true)).toBe(
      'clearance_export_bulk_with_customs',
    );
    expect(clearanceSettingCode('EXPORT', 'BULK', false)).toBe(
      'clearance_export_bulk_without_customs',
    );
  });

  it('returns null for DOMESTIC (no clearance gate)', () => {
    expect(clearanceSettingCode('DOMESTIC', 'CONTAINER', true)).toBeNull();
    expect(clearanceSettingCode('DOMESTIC', 'BULK', false)).toBeNull();
  });
});

describe('clearance.util — clearanceOutputSettingCode', () => {
  it('returns a container output code only for customs container bookings', () => {
    expect(clearanceOutputSettingCode('IMPORT', 'CONTAINER', true)).toBe(
      'clearance_output_import_container',
    );
    expect(clearanceOutputSettingCode('EXPORT', 'CONTAINER', true)).toBe(
      'clearance_output_export_container',
    );
  });

  it('returns null without customs', () => {
    expect(clearanceOutputSettingCode('IMPORT', 'CONTAINER', false)).toBeNull();
  });

  it('returns null for bulk (no container output set) and domestic', () => {
    expect(clearanceOutputSettingCode('IMPORT', 'BULK', true)).toBeNull();
    expect(clearanceOutputSettingCode('DOMESTIC', 'CONTAINER', true)).toBeNull();
  });
});
