import 'package:flutter_test/flutter_test.dart';
import 'package:hwhub/utils/scanner_utils.dart';

void main() {
  group('extractHwIdFromLines', () {
    test('returns first matching HW ID', () {
      final result = extractHwIdFromLines([
        'some random text',
        'MODEL JKF21 PREMIUM',
        'another HCV73',
      ]);

      expect(result, 'JKF21');
    });

    test('matches lower-case input by normalizing to upper-case', () {
      final result = extractHwIdFromLines([
        'abc',
        'new release grx33',
      ]);

      expect(result, 'GRX33');
    });

    test('returns null when no pattern is present', () {
      final result = extractHwIdFromLines([
        'hot wheels',
        'no sku here',
      ]);

      expect(result, isNull);
    });

    test('supports 2 to 5 letters and 2 to 4 digits', () {
      expect(extractHwIdFromLines(['AB12']), 'AB12');
      expect(extractHwIdFromLines(['ABCDE1234']), 'ABCDE1234');
    });
  });
}
