import 'package:flutter_test/flutter_test.dart';
import 'package:marianum_mobile/push/nid_store.dart';

void main() {
  group('NidEntry', () {
    test('round-trips through JSON with a chat token', () {
      const entry = NidEntry(
        nid: 42,
        notificationId: 42,
        tag: 'talk_abc123',
        chatToken: 'abc123',
      );
      final restored = NidEntry.fromJson(entry.toJson());
      expect(restored.nid, 42);
      expect(restored.notificationId, 42);
      expect(restored.tag, 'talk_abc123');
      expect(restored.chatToken, 'abc123');
    });

    test('omits the chat token when absent', () {
      const entry = NidEntry(nid: 7, notificationId: 7, tag: 'nc_7');
      final json = entry.toJson();
      expect(json.containsKey('chatToken'), isFalse);
      final restored = NidEntry.fromJson(json);
      expect(restored.chatToken, isNull);
      expect(restored.tag, 'nc_7');
    });
  });
}
