feat(stream_chat): upgrade to null safe dependencies

This commit is contained in:
Felix Angelov
2021-03-21 23:27:26 -05:00
parent b653ec34d3
commit 67f62d0692
24 changed files with 1460 additions and 1032 deletions
@@ -5,7 +5,7 @@ import 'package:stream_chat/src/models/action.dart';
void main() {
group('src/models/action', () {
const jsonExample = r'''{
const jsonExample = '''{
"name": "name",
"style": "style",
"text": "text",
@@ -1,12 +1,12 @@
import 'dart:convert';
import 'package:stream_chat/src/models/attachment.dart';
import 'package:stream_chat/src/models/action.dart';
import 'dart:convert';
import 'package:test/test.dart';
void main() {
group('src/models/attachment', () {
const jsonExample = r'''{
const jsonExample = '''{
"type": "giphy",
"title": "awesome",
"title_link": "https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti",
@@ -38,22 +38,27 @@ void main() {
test('should parse json correctly', () {
final attachment = Attachment.fromJson(json.decode(jsonExample));
expect(attachment.type, "giphy");
expect(attachment.title, "awesome");
expect(attachment.titleLink,
"https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti");
expect(attachment.thumbUrl,
"https://media0.giphy.com/media/3o7TKnCdBx5cMg0qti/giphy.gif");
expect(attachment.type, 'giphy');
expect(attachment.title, 'awesome');
expect(
attachment.titleLink,
'https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti',
);
expect(
attachment.thumbUrl,
'https://media0.giphy.com/media/3o7TKnCdBx5cMg0qti/giphy.gif',
);
expect(attachment.actions, hasLength(3));
expect(attachment.actions[0], isA<Action>());
});
test('should serialize to json correctly', () {
final channel = Attachment(
type: "image",
title: "soo",
titleLink:
"https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti");
type: 'image',
title: 'soo',
titleLink:
'https://giphy.com/gifs/nrkp3-dance-happy-3o7TKnCdBx5cMg0qti',
);
expect(
channel.toJson(),
@@ -10,7 +10,7 @@ import 'package:stream_chat/stream_chat.dart';
void main() {
group('src/models/channel_state', () {
const jsonExample = r'''{
const jsonExample = '''{
"channel": {
"id": "dev",
"type": "team",
@@ -853,28 +853,32 @@ void main() {
expect(channelState.channel.config.commands, hasLength(1));
expect(channelState.channel.config.commands[0], isA<Command>());
expect(channelState.channel.lastMessageAt,
DateTime.parse("2020-01-30T13:43:41.062362Z"));
DateTime.parse('2020-01-30T13:43:41.062362Z'));
expect(channelState.channel.createdAt,
DateTime.parse("2019-04-03T18:43:33.213373Z"));
DateTime.parse('2019-04-03T18:43:33.213373Z'));
expect(channelState.channel.updatedAt,
DateTime.parse("2019-04-03T18:43:33.213374Z"));
DateTime.parse('2019-04-03T18:43:33.213374Z'));
expect(channelState.channel.createdBy, isA<User>());
expect(channelState.channel.frozen, true);
expect(channelState.channel.extraData['example'], 1);
expect(channelState.channel.extraData['name'], "#dev");
expect(channelState.channel.extraData['image'],
"https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png");
expect(channelState.channel.extraData['name'], '#dev');
expect(
channelState.channel.extraData['image'],
'https://cdn.chrisshort.net/testing-certificate-chains-in-go/GOPHER_MIC_DROP.png',
);
expect(channelState.messages, hasLength(25));
expect(channelState.messages[0], isA<Message>());
expect(channelState.messages[0], isNotNull);
expect(channelState.messages[0].createdAt,
DateTime.parse("2020-01-29T03:23:02.843948Z"));
expect(
channelState.messages[0].createdAt,
DateTime.parse('2,020-01-29T03:23:02.843948Z'),
);
expect(channelState.messages[0].user, isA<User>());
expect(channelState.watcherCount, 5);
});
test('should serialize to json correctly', () {
const toJsonExample = r'''
const toJsonExample = '''
{
"channel": {
"id": "dev",
@@ -17,19 +17,19 @@ void main() {
test('should parse json correctly', () {
final channel = ChannelModel.fromJson(json.decode(jsonExample));
expect(channel.id, equals("test"));
expect(channel.type, equals("livestream"));
expect(channel.cid, equals("test:livestream"));
expect(channel.extraData["cats"], equals(true));
expect(channel.extraData["fruit"], equals(["bananas", "apples"]));
expect(channel.id, equals('test'));
expect(channel.type, equals('livestream'));
expect(channel.cid, equals('test:livestream'));
expect(channel.extraData['cats'], equals(true));
expect(channel.extraData['fruit'], equals(['bananas', 'apples']));
});
test('should serialize to json correctly', () {
final channel = ChannelModel(
type: "type",
id: "id",
cid: "a:a",
extraData: {"name": "cool"},
type: 'type',
id: 'id',
cid: 'a:a',
extraData: {'name': 'cool'},
);
expect(
@@ -40,10 +40,10 @@ void main() {
test('should serialize to json correctly when frozen is provided', () {
final channel = ChannelModel(
type: "type",
id: "id",
cid: "a:a",
extraData: {"name": "cool"},
type: 'type',
id: 'id',
cid: 'a:a',
extraData: {'name': 'cool'},
frozen: false,
);
@@ -1,6 +1,6 @@
import 'package:stream_chat/src/models/command.dart';
import 'dart:convert';
import 'package:stream_chat/src/models/command.dart';
import 'package:test/test.dart';
void main() {
@@ -30,9 +30,9 @@ void main() {
expect(
command.toJson(),
{
"name": "giphy",
"description": "Post a random gif to the channel",
"args": "[text]",
'name': 'giphy',
'description': 'Post a random gif to the channel',
'args': '[text]',
},
);
});
@@ -5,7 +5,7 @@ import 'package:stream_chat/src/models/device.dart';
void main() {
group('src/models/device', () {
const jsonExample = r'''{
const jsonExample = '''{
"id": "device-id",
"push_provider": "push-provider"
}''';
@@ -55,7 +55,7 @@ void main() {
type: 'type',
cid: 'cid',
connectionId: 'connectionId',
createdAt: DateTime.parse("2020-01-29T03:22:47.63613Z"),
createdAt: DateTime.parse('2020-01-29T03:22:47.63613Z'),
me: OwnUser(id: 'id2'),
totalUnreadCount: 1,
unreadChannels: 1,
@@ -28,8 +28,8 @@ void main() {
final member = Member.fromJson(json.decode(jsonExample));
expect(member.user, isA<User>());
expect(member.role, 'member');
expect(member.createdAt, DateTime.parse("2020-01-28T22:17:30.95443Z"));
expect(member.updatedAt, DateTime.parse("2020-01-28T22:17:30.95443Z"));
expect(member.createdAt, DateTime.parse('2020-01-28T22:17:30.95443Z'));
expect(member.updatedAt, DateTime.parse('2020-01-28T22:17:30.95443Z'));
});
});
}
@@ -76,10 +76,10 @@ void main() {
test('should parse json correctly', () {
final message = Message.fromJson(json.decode(jsonExample));
expect(message.id, "4637f7e4-a06b-42db-ba5a-8d8270dd926f");
expect(message.id, '4637f7e4-a06b-42db-ba5a-8d8270dd926f');
expect(message.text,
"https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA");
expect(message.type, "regular");
'https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA');
expect(message.type, 'regular');
expect(message.user, isA<User>());
expect(message.silent, isA<bool>());
expect(message.attachments, isA<List<Attachment>>());
@@ -87,8 +87,8 @@ void main() {
expect(message.ownReactions, isA<List<Reaction>>());
expect(message.reactionCounts, {'love': 1});
expect(message.reactionScores, {'love': 1});
expect(message.createdAt, DateTime.parse("2020-01-28T22:17:31.107978Z"));
expect(message.updatedAt, DateTime.parse("2020-01-28T22:17:31.130506Z"));
expect(message.createdAt, DateTime.parse('2020-01-28T22:17:31.107978Z'));
expect(message.updatedAt, DateTime.parse('2020-01-28T22:17:31.130506Z'));
expect(message.mentionedUsers, isA<List<User>>());
expect(message.pinned, false);
expect(message.pinnedAt, null);
@@ -98,38 +98,37 @@ void main() {
test('should serialize to json correctly', () {
final message = Message(
id: "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
id: '4637f7e4-a06b-42db-ba5a-8d8270dd926f',
text:
"https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
'https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA',
silent: false,
attachments: [
Attachment.fromJson({
"type": "video",
"author_name": "GIPHY",
"title": "The Lion King Disney GIF - Find \u0026 Share on GIPHY",
"title_link":
"https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"text":
"Discover \u0026 share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.",
"image_url":
"https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"thumb_url":
"https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif",
"asset_url":
"https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4",
"og_scrape_url":
"https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA"
'type': 'video',
'author_name': 'GIPHY',
'title': 'The Lion King Disney GIF - Find \u0026 Share on GIPHY',
'title_link':
'https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif',
'text':
'''Discover \u0026 share this Lion King Live Action GIF with everyone you know. GIPHY is how you search, share, discover, and create GIFs.''',
'image_url':
'https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif',
'thumb_url':
'https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.gif',
'asset_url':
'https://media.giphy.com/media/5zvN79uTGfLMOVfQaA/giphy.mp4',
'og_scrape_url':
'https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA'
})
],
showInChannel: true,
parentId: 'parentId',
extraData: {'hey': 'test'},
status: MessageSendingStatus.sent,
);
expect(
message.toJson(),
json.decode(r'''
json.decode('''
{
"id": "4637f7e4-a06b-42db-ba5a-8d8270dd926f",
"text": "https://giphy.com/gifs/the-lion-king-live-action-5zvN79uTGfLMOVfQaA",
@@ -1,7 +1,7 @@
import 'package:test/test.dart';
import 'package:stream_chat/src/models/reaction.dart';
import 'dart:convert';
import 'package:test/test.dart';
import 'package:stream_chat/src/models/reaction.dart';
import 'package:stream_chat/src/models/user.dart';
void main() {
@@ -30,13 +30,13 @@ void main() {
test('should parse json correctly', () {
final reaction = Reaction.fromJson(json.decode(jsonExample));
expect(reaction.messageId, '76cd8c82-b557-4e48-9d12-87995d3a0e04');
expect(reaction.createdAt, DateTime.parse("2020-01-28T22:17:31.108742Z"));
expect(reaction.createdAt, DateTime.parse('2020-01-28T22:17:31.108742Z'));
expect(reaction.type, 'wow');
expect(
reaction.user.toJson(),
User.init("2de0297c-f3f2-489d-b930-ef77342edccf", extraData: {
"image": "https://randomuser.me/api/portraits/women/45.jpg",
"name": "Daisy Morgan"
User.init('2de0297c-f3f2-489d-b930-ef77342edccf', extraData: {
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
'name': 'Daisy Morgan'
}).toJson(),
);
expect(reaction.score, 1);
@@ -47,13 +47,13 @@ void main() {
test('should serialize to json correctly', () {
final reaction = Reaction(
messageId: '76cd8c82-b557-4e48-9d12-87995d3a0e04',
createdAt: DateTime.parse("2020-01-28T22:17:31.108742Z"),
createdAt: DateTime.parse('2020-01-28T22:17:31.108742Z'),
type: 'wow',
user: User.init("2de0297c-f3f2-489d-b930-ef77342edccf", extraData: {
"image": "https://randomuser.me/api/portraits/women/45.jpg",
"name": "Daisy Morgan"
user: User.init('2de0297c-f3f2-489d-b930-ef77342edccf', extraData: {
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
'name': 'Daisy Morgan'
}),
userId: "2de0297c-f3f2-489d-b930-ef77342edccf",
userId: '2de0297c-f3f2-489d-b930-ef77342edccf',
extraData: {'bananas': 'yes'},
score: 1,
);
@@ -61,10 +61,10 @@ void main() {
expect(
reaction.toJson(),
{
"message_id": "76cd8c82-b557-4e48-9d12-87995d3a0e04",
"type": "wow",
"score": 1,
"bananas": 'yes',
'message_id': '76cd8c82-b557-4e48-9d12-87995d3a0e04',
'type': 'wow',
'score': 1,
'bananas': 'yes',
},
);
});
@@ -31,8 +31,8 @@ void main() {
);
expect(read.toJson(), {
"user": {"id": "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e"},
"last_read": "2020-01-28T22:17:30.966485Z",
'user': {'id': 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e'},
'last_read': '2020-01-28T22:17:30.966485Z',
'unread_messages': 10,
});
});
@@ -17,11 +17,13 @@ void main() {
});
test('should serialize to json correctly', () {
final user =
User(id: 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e', role: "abc");
final user = User(
id: 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e',
role: 'abc',
);
expect(user.toJson(), {
'id': "bbb19d9a-ee50-45bc-84e5-0584e79d0c9e",
'id': 'bbb19d9a-ee50-45bc-84e5-0584e79d0c9e',
});
});
});