1- // ignore_for_file: avoid_redundant_argument_values
2-
31import 'dart:async' ;
42import 'dart:convert' ;
53
@@ -9,8 +7,7 @@ import 'package:stream_feeds/src/state/activity_state.dart';
97import 'package:stream_feeds/stream_feeds.dart' ;
108import 'package:test/test.dart' ;
119
12- import '../mocks.dart' ;
13- import '../ws_test_helpers.dart' ;
10+ import '../test_utils.dart' ;
1411
1512void main () {
1613 late StreamFeedsClientImpl client;
@@ -47,7 +44,7 @@ void main() {
4744 depth: 3 ,
4845 ),
4946 ).thenAnswer (
50- (_) async => const Result .success (defaultCommentsResponse ),
47+ (_) async => Result .success (createDefaultCommentsResponse () ),
5148 );
5249
5350 final activity = client.activity (
@@ -102,7 +99,7 @@ void main() {
10299 depth: 3 ,
103100 ),
104101 ).thenAnswer (
105- (_) async => const Result .success (defaultCommentsResponse ),
102+ (_) async => Result .success (createDefaultCommentsResponse () ),
106103 );
107104 }
108105
@@ -146,7 +143,7 @@ void main() {
146143 optionId: firstOptionId,
147144 pollId: pollId,
148145 ),
149- type: 'feeds.poll.vote_casted' ,
146+ type: EventTypes .pollVoteCasted ,
150147 ).toJson (),
151148 ),
152149 );
@@ -191,7 +188,7 @@ void main() {
191188 optionId: 'optionId1' ,
192189 pollId: 'pollId1' ,
193190 ),
194- type: 'feeds.poll.vote_casted' ,
191+ type: EventTypes .pollVoteCasted ,
195192 ),
196193 ),
197194 );
@@ -251,7 +248,7 @@ void main() {
251248 optionId: 'optionId1' ,
252249 pollId: 'pollId1' ,
253250 ),
254- type: 'feeds.poll.vote_removed' ,
251+ type: EventTypes .pollVoteRemoved ,
255252 ),
256253 ),
257254 );
@@ -309,7 +306,7 @@ void main() {
309306 optionId: 'optionId1' ,
310307 pollId: pollId,
311308 ),
312- type: 'feeds.poll.vote_removed' ,
309+ type: EventTypes .pollVoteRemoved ,
313310 ),
314311 ),
315312 );
@@ -344,7 +341,7 @@ void main() {
344341 custom: const {},
345342 fid: 'fid' ,
346343 poll: poll.copyWith (isClosed: true ),
347- type: 'feeds.poll.closed' ,
344+ type: EventTypes .pollClosed ,
348345 ),
349346 ),
350347 );
@@ -378,106 +375,10 @@ void main() {
378375 custom: const {},
379376 fid: 'fid' ,
380377 poll: poll,
381- type: 'feeds.poll.deleted' ,
378+ type: EventTypes .pollDeleted ,
382379 ),
383380 ),
384381 );
385382 });
386383 });
387384}
388-
389- const defaultCommentsResponse = GetCommentsResponse (
390- comments: [],
391- next: null ,
392- prev: null ,
393- duration: 'duration' ,
394- );
395-
396- GetActivityResponse createDefaultActivityResponse ({PollResponseData ? poll}) =>
397- GetActivityResponse (
398- activity: ActivityResponse (
399- id: 'id' ,
400- attachments: const [],
401- bookmarkCount: 0 ,
402- commentCount: 0 ,
403- comments: const [],
404- createdAt: DateTime (2021 , 1 , 1 ),
405- custom: const {},
406- feeds: const [],
407- filterTags: const [],
408- interestTags: const [],
409- latestReactions: const [],
410- mentionedUsers: const [],
411- moderation: null ,
412- notificationContext: null ,
413- ownBookmarks: const [],
414- ownReactions: const [],
415- parent: null ,
416- poll: poll,
417- popularity: 0 ,
418- reactionCount: 0 ,
419- reactionGroups: const {},
420- score: 0 ,
421- searchData: const {},
422- shareCount: 0 ,
423- text: null ,
424- type: 'type' ,
425- updatedAt: DateTime (2021 , 2 , 1 ),
426- user: UserResponse (
427- id: 'id' ,
428- name: 'name' ,
429- banned: false ,
430- blockedUserIds: const [],
431- createdAt: DateTime (2021 , 1 , 1 ),
432- custom: const {},
433- language: 'language' ,
434- online: false ,
435- role: 'role' ,
436- teams: const [],
437- updatedAt: DateTime (2021 , 2 , 1 ),
438- ),
439- visibility: ActivityResponseVisibility .public,
440- visibilityTag: null ,
441- ),
442- duration: 'duration' ,
443- );
444-
445- PollResponseData createDefaultPollResponseData ({
446- List <PollVoteResponseData > latestAnswers = const [],
447- Map <String , List <PollVoteResponseData >> latestVotesByOption = const {},
448- }) =>
449- PollResponseData (
450- id: 'id' ,
451- name: 'name' ,
452- allowAnswers: true ,
453- allowUserSuggestedOptions: true ,
454- answersCount: latestAnswers.length,
455- createdAt: DateTime .now (),
456- createdById: 'id' ,
457- custom: const {},
458- description: 'description' ,
459- enforceUniqueVote: true ,
460- latestAnswers: latestAnswers,
461- latestVotesByOption: latestVotesByOption,
462- ownVotes: const [],
463- updatedAt: DateTime .now (),
464- voteCount: latestVotesByOption.values
465- .map ((e) => e.length)
466- .fold (0 , (v, e) => v + e),
467- voteCountsByOption: latestVotesByOption.map (
468- (k, e) => MapEntry (k, e.length),
469- ),
470- votingVisibility: 'visibility' ,
471- options: const [
472- PollOptionResponseData (
473- id: 'id1' ,
474- text: 'text1' ,
475- custom: {},
476- ),
477- PollOptionResponseData (
478- id: 'id2' ,
479- text: 'text2' ,
480- custom: {},
481- ),
482- ],
483- );
0 commit comments