import 'package:flutter_test/flutter_test.dart';
import 'package:unionflow_mobile_apps/features/devise/domain/entities/devise.dart';

void main() {
  group('Devise enum', () {
    test('reference = XOF', () {
      expect(Devise.reference(), Devise.xof);
    });

    test('fromCode parse correct', () {
      expect(Devise.fromCode('EUR'), Devise.eur);
      expect(Devise.fromCode('usd'), Devise.usd);
      expect(Devise.fromCode('GBP'), Devise.gbp);
    });

    test('fromCode null/vide/inconnu → XOF (référence)', () {
      expect(Devise.fromCode(null), Devise.xof);
      expect(Devise.fromCode(''), Devise.xof);
      expect(Devise.fromCode('XYZ'), Devise.xof);
    });

    test('estInternationale — EUR/USD/GBP/CAD/CHF → true', () {
      expect(Devise.eur.estInternationale, isTrue);
      expect(Devise.usd.estInternationale, isTrue);
      expect(Devise.gbp.estInternationale, isTrue);
      expect(Devise.cad.estInternationale, isTrue);
      expect(Devise.chf.estInternationale, isTrue);
    });

    test('estInternationale — XOF/XAF/GHS/NGN/MAD → false', () {
      expect(Devise.xof.estInternationale, isFalse);
      expect(Devise.xaf.estInternationale, isFalse);
      expect(Devise.ghs.estInternationale, isFalse);
      expect(Devise.ngn.estInternationale, isFalse);
      expect(Devise.mad.estInternationale, isFalse);
    });

    test('Toutes les devises ont code 3 lettres + libellé non vide + zone', () {
      for (final d in Devise.values) {
        expect(d.code.length, 3);
        expect(d.libelle.isNotEmpty, isTrue);
        expect(d.zone.isNotEmpty, isTrue);
      }
    });
  });
}
