@@ -9,8 +9,7 @@ import 'package:stream_feeds/src/state/activity_state.dart';
99import 'package:stream_feeds/stream_feeds.dart' ;
1010import 'package:test/test.dart' ;
1111
12- import '../mocks.dart' ;
13- import '../ws_test_helpers.dart' ;
12+ import '../test_utils.dart' ;
1413
1514void main () {
1615 late StreamFeedsClientImpl client;
@@ -47,7 +46,7 @@ void main() {
4746 depth: 3 ,
4847 ),
4948 ).thenAnswer (
50- (_) async => const Result .success (defaultCommentsResponse ),
49+ (_) async => Result .success (createDefaultCommentsResponse () ),
5150 );
5251
5352 final activity = client.activity (
@@ -102,7 +101,7 @@ void main() {
102101 depth: 3 ,
103102 ),
104103 ).thenAnswer (
105- (_) async => const Result .success (defaultCommentsResponse ),
104+ (_) async => Result .success (createDefaultCommentsResponse () ),
106105 );
107106 }
108107
@@ -146,7 +145,7 @@ void main() {
146145 optionId: firstOptionId,
147146 pollId: pollId,
148147 ),
149- type: 'feeds.poll.vote_casted' ,
148+ type: EventTypes .pollVoteCasted ,
150149 ).toJson (),
151150 ),
152151 );
@@ -191,7 +190,7 @@ void main() {
191190 optionId: 'optionId1' ,
192191 pollId: 'pollId1' ,
193192 ),
194- type: 'feeds.poll.vote_casted' ,
193+ type: EventTypes .pollVoteCasted ,
195194 ),
196195 ),
197196 );
@@ -251,7 +250,7 @@ void main() {
251250 optionId: 'optionId1' ,
252251 pollId: 'pollId1' ,
253252 ),
254- type: 'feeds.poll.vote_removed' ,
253+ type: EventTypes .pollVoteRemoved ,
255254 ),
256255 ),
257256 );
@@ -309,7 +308,7 @@ void main() {
309308 optionId: 'optionId1' ,
310309 pollId: pollId,
311310 ),
312- type: 'feeds.poll.vote_removed' ,
311+ type: EventTypes .pollVoteRemoved ,
313312 ),
314313 ),
315314 );
@@ -344,7 +343,7 @@ void main() {
344343 custom: const {},
345344 fid: 'fid' ,
346345 poll: poll.copyWith (isClosed: true ),
347- type: 'feeds.poll.closed' ,
346+ type: EventTypes .pollClosed ,
348347 ),
349348 ),
350349 );
@@ -378,106 +377,10 @@ void main() {
378377 custom: const {},
379378 fid: 'fid' ,
380379 poll: poll,
381- type: 'feeds.poll.deleted' ,
380+ type: EventTypes .pollDeleted ,
382381 ),
383382 ),
384383 );
385384 });
386385 });
387386}
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