import 'package:flutter_test/flutter_test.dart';
import 'package:marianum_mobile/share_intent/pending_share.dart';

PendingShare _share({
  List<String> filePaths = const [],
  String? text,
  DateTime? receivedAt,
}) => PendingShare(
  filePaths: filePaths,
  text: text,
  receivedAt: receivedAt ?? DateTime(2026, 1, 1),
);

void main() {
  group('PendingShare.contentEquals', () {
    test('equal payloads compare equal regardless of receivedAt', () {
      final a = _share(
        filePaths: ['/tmp/a.jpg', '/tmp/b.jpg'],
        text: 'hi',
        receivedAt: DateTime(2026, 1, 1),
      );
      final b = _share(
        filePaths: ['/tmp/a.jpg', '/tmp/b.jpg'],
        text: 'hi',
        receivedAt: DateTime(2026, 1, 1, 0, 0, 1),
      );

      expect(a.contentEquals(b), isTrue);
      expect(b.contentEquals(a), isTrue);
    });

    test('differing text is not equal', () {
      final a = _share(filePaths: ['/tmp/a.jpg'], text: 'hi');
      final b = _share(filePaths: ['/tmp/a.jpg'], text: 'ho');

      expect(a.contentEquals(b), isFalse);
    });

    test('null text vs text is not equal', () {
      final a = _share(filePaths: ['/tmp/a.jpg']);
      final b = _share(filePaths: ['/tmp/a.jpg'], text: 'hi');

      expect(a.contentEquals(b), isFalse);
    });

    test('differing file lists are not equal', () {
      final a = _share(filePaths: ['/tmp/a.jpg']);
      final b = _share(filePaths: ['/tmp/b.jpg']);
      final c = _share(filePaths: ['/tmp/a.jpg', '/tmp/b.jpg']);

      expect(a.contentEquals(b), isFalse);
      expect(a.contentEquals(c), isFalse);
    });

    test('file order matters', () {
      final a = _share(filePaths: ['/tmp/a.jpg', '/tmp/b.jpg']);
      final b = _share(filePaths: ['/tmp/b.jpg', '/tmp/a.jpg']);

      expect(a.contentEquals(b), isFalse);
    });

    test('empty shares compare equal', () {
      expect(_share().contentEquals(_share()), isTrue);
    });
  });
}
