diff --git a/packages/stream_chat/lib/src/core/models/channel_config.dart b/packages/stream_chat/lib/src/core/models/channel_config.dart index 2d5182b3..b7cafac6 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.dart @@ -4,7 +4,7 @@ import 'package:stream_chat/src/core/models/command.dart'; part 'channel_config.g.dart'; /// The class that contains the information about the configuration of a channel -@JsonSerializable() +@JsonSerializable(createToJson: false) class ChannelConfig { /// Constructor used for json serialization ChannelConfig({ @@ -87,7 +87,4 @@ class ChannelConfig { /// True if urls appears as attachments @JsonKey(defaultValue: false) final bool urlEnrichment; - - /// Serialize to json - Map toJson() => _$ChannelConfigToJson(this); } diff --git a/packages/stream_chat/lib/src/core/models/channel_config.g.dart b/packages/stream_chat/lib/src/core/models/channel_config.g.dart index 723281c0..b01049f3 100644 --- a/packages/stream_chat/lib/src/core/models/channel_config.g.dart +++ b/packages/stream_chat/lib/src/core/models/channel_config.g.dart @@ -32,22 +32,3 @@ ChannelConfig _$ChannelConfigFromJson(Map json) { urlEnrichment: json['url_enrichment'] as bool? ?? false, ); } - -Map _$ChannelConfigToJson(ChannelConfig instance) => - { - 'automod': instance.automod, - 'commands': instance.commands.map((e) => e.toJson()).toList(), - 'connect_events': instance.connectEvents, - 'created_at': instance.createdAt.toIso8601String(), - 'updated_at': instance.updatedAt.toIso8601String(), - 'max_message_length': instance.maxMessageLength, - 'message_retention': instance.messageRetention, - 'mutes': instance.mutes, - 'reactions': instance.reactions, - 'read_events': instance.readEvents, - 'replies': instance.replies, - 'search': instance.search, - 'typing_events': instance.typingEvents, - 'uploads': instance.uploads, - 'url_enrichment': instance.urlEnrichment, - }; diff --git a/packages/stream_chat/test/fixtures/user.json b/packages/stream_chat/test/fixtures/user.json index 1fad8ea0..49b972a3 100644 --- a/packages/stream_chat/test/fixtures/user.json +++ b/packages/stream_chat/test/fixtures/user.json @@ -1,4 +1,5 @@ { "id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e", - "role": "test-role" + "role": "test-role", + "name": "John" } \ No newline at end of file diff --git a/packages/stream_chat/test/src/core/models/user_test.dart b/packages/stream_chat/test/src/core/models/user_test.dart index 89d22b30..ce488cab 100644 --- a/packages/stream_chat/test/src/core/models/user_test.dart +++ b/packages/stream_chat/test/src/core/models/user_test.dart @@ -8,6 +8,7 @@ void main() { test('should parse json correctly', () { final user = User.fromJson(jsonFixture('user.json')); expect(user.id, 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e'); + expect(user.name, 'John'); }); test('should serialize to json correctly', () { @@ -20,5 +21,26 @@ void main() { 'id': 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e', }); }); + + test('copyWith', () { + final user = User.fromJson(jsonFixture('user.json')); + var newUser = user.copyWith(); + + expect(newUser.id, user.id); + expect(newUser.role, user.role); + expect(newUser.name, user.name); + + newUser = user.copyWith( + id: 'test', + role: 'test', + extraData: { + 'name': 'test', + }, + ); + + expect(newUser.id, 'test'); + expect(newUser.role, 'test'); + expect(newUser.name, 'test'); + }); }); }