add reaction test
This commit is contained in:
@@ -47,5 +47,108 @@ void main() {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('copyWith', () {
|
||||
final reaction = Reaction.fromJson(jsonFixture('reaction.json'));
|
||||
var newReaction = reaction.copyWith();
|
||||
expect(newReaction.messageId, '76cd8c82-b557-4e48-9d12-87995d3a0e04');
|
||||
expect(
|
||||
newReaction.createdAt, DateTime.parse('2020-01-28T22:17:31.108742Z'));
|
||||
expect(newReaction.type, 'wow');
|
||||
expect(
|
||||
newReaction.user?.toJson(),
|
||||
User(id: '2de0297c-f3f2-489d-b930-ef77342edccf', extraData: const {
|
||||
'image': 'https://randomuser.me/api/portraits/women/45.jpg',
|
||||
'name': 'Daisy Morgan',
|
||||
}).toJson(),
|
||||
);
|
||||
expect(newReaction.score, 1);
|
||||
expect(newReaction.userId, '2de0297c-f3f2-489d-b930-ef77342edccf');
|
||||
expect(
|
||||
newReaction.extraData, {'updated_at': '2020-01-28T22:17:31.108742Z'});
|
||||
|
||||
newReaction = reaction.copyWith(
|
||||
type: 'lol',
|
||||
createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'),
|
||||
extraData: {},
|
||||
messageId: 'test',
|
||||
score: 2,
|
||||
user: User(id: 'test'),
|
||||
userId: 'test',
|
||||
);
|
||||
|
||||
expect(
|
||||
newReaction.type,
|
||||
'lol',
|
||||
);
|
||||
expect(
|
||||
newReaction.createdAt,
|
||||
DateTime.parse('2021-01-28T22:17:31.108742Z'),
|
||||
);
|
||||
expect(
|
||||
newReaction.extraData,
|
||||
{},
|
||||
);
|
||||
expect(
|
||||
newReaction.messageId,
|
||||
'test',
|
||||
);
|
||||
expect(
|
||||
newReaction.score,
|
||||
2,
|
||||
);
|
||||
expect(
|
||||
newReaction.user,
|
||||
User(id: 'test'),
|
||||
);
|
||||
expect(
|
||||
newReaction.userId,
|
||||
'test',
|
||||
);
|
||||
});
|
||||
|
||||
test('merge', () {
|
||||
final reaction = Reaction.fromJson(jsonFixture('reaction.json'));
|
||||
final newReaction = reaction.merge(
|
||||
Reaction(
|
||||
type: 'lol',
|
||||
createdAt: DateTime.parse('2021-01-28T22:17:31.108742Z'),
|
||||
extraData: {},
|
||||
messageId: 'test',
|
||||
score: 2,
|
||||
user: User(id: 'test'),
|
||||
userId: 'test',
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
newReaction.type,
|
||||
'lol',
|
||||
);
|
||||
expect(
|
||||
newReaction.createdAt,
|
||||
DateTime.parse('2021-01-28T22:17:31.108742Z'),
|
||||
);
|
||||
expect(
|
||||
newReaction.extraData,
|
||||
{},
|
||||
);
|
||||
expect(
|
||||
newReaction.messageId,
|
||||
'test',
|
||||
);
|
||||
expect(
|
||||
newReaction.score,
|
||||
2,
|
||||
);
|
||||
expect(
|
||||
newReaction.user,
|
||||
User(id: 'test'),
|
||||
);
|
||||
expect(
|
||||
newReaction.userId,
|
||||
'test',
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user