@@ -619,7 +619,7 @@ void main() {
619
619
group ('handleSubmessageEvent' , () {
620
620
Future <Message > preparePollMessage ({
621
621
String ? question,
622
- List <PollOption > ? options ,
622
+ List <( String , Iterable < int >)> ? optionVoterIdsPairs ,
623
623
User ? messageSender,
624
624
}) async {
625
625
final effectiveMessageSender = messageSender ?? eg.selfUser;
@@ -628,13 +628,13 @@ void main() {
628
628
eg.submessage (senderId: effectiveMessageSender.userId,
629
629
content: eg.pollWidgetData (
630
630
question: question ?? 'example question' ,
631
- options: (options != null )
632
- ? options .map ((e) => e.text ).toList ()
631
+ options: (optionVoterIdsPairs != null )
632
+ ? optionVoterIdsPairs .map ((e) => e.$1 ).toList ()
633
633
: ['foo' , 'bar' ])),
634
- if (options != null )
635
- for (int i = 0 ; i < options .length; i++ )
634
+ if (optionVoterIdsPairs != null )
635
+ for (int i = 0 ; i < optionVoterIdsPairs .length; i++ )
636
636
...[
637
- for (final voter in options [i].voters )
637
+ for (final voter in optionVoterIdsPairs [i].$2 )
638
638
eg.submessage (senderId: voter,
639
639
content: PollVoteEventSubmessage (
640
640
key: PollEventSubmessage .optionKey (senderId: null , idx: i),
@@ -726,7 +726,7 @@ void main() {
726
726
727
727
test ('add option' , () async {
728
728
message = await preparePollMessage (
729
- options : [eg. pollOption (text : 'bar' , voters : [])]);
729
+ optionVoterIdsPairs : [( 'bar' , [])]);
730
730
await handleNewOptionEvent (eg.otherUser, option: 'baz' , idx: 0 );
731
731
checkPoll (message).options.deepEquals ([
732
732
conditionPollOption ('bar' ),
@@ -736,7 +736,7 @@ void main() {
736
736
737
737
test ('option with duplicate text ignored' , () async {
738
738
message = await preparePollMessage (
739
- options : [eg. pollOption (text : 'existing' , voters : [])]);
739
+ optionVoterIdsPairs : [( 'existing' , [])]);
740
740
checkPoll (message).options.deepEquals ([conditionPollOption ('existing' )]);
741
741
await handleNewOptionEvent (eg.otherUser, option: 'existing' , idx: 0 );
742
742
checkPoll (message).options.deepEquals ([conditionPollOption ('existing' )]);
@@ -745,7 +745,7 @@ void main() {
745
745
test ('option index limit exceeded' , () async {
746
746
message = await preparePollMessage (
747
747
question: 'favorite number' ,
748
- options : List .generate (1001 , (i) => eg. pollOption (text : '$i ' , voters : [])),
748
+ optionVoterIdsPairs : List .generate (1001 , (i) => ( '$i ' , [])),
749
749
);
750
750
checkPoll (message).options.length.equals (1001 );
751
751
await handleNewOptionEvent (eg.otherUser, option: 'baz' , idx: 1001 );
@@ -788,9 +788,9 @@ void main() {
788
788
});
789
789
790
790
test ('remove votes' , () async {
791
- message = await preparePollMessage (options : [
792
- eg. pollOption (text : 'foo' , voters : [eg.otherUser.userId, eg.selfUser.userId]),
793
- eg. pollOption (text : 'bar' , voters : [eg.selfUser.userId]),
791
+ message = await preparePollMessage (optionVoterIdsPairs : [
792
+ ( 'foo' , [eg.otherUser.userId, eg.selfUser.userId]),
793
+ ( 'bar' , [eg.selfUser.userId]),
794
794
]);
795
795
796
796
String optionKey (int index) =>
@@ -810,9 +810,9 @@ void main() {
810
810
});
811
811
812
812
test ('vote for unknown options' , () async {
813
- message = await preparePollMessage (options : [
814
- eg. pollOption (text : 'foo' , voters : [eg.selfUser.userId]),
815
- eg. pollOption (text : 'bar' , voters : []),
813
+ message = await preparePollMessage (optionVoterIdsPairs : [
814
+ ( 'foo' , [eg.selfUser.userId]),
815
+ ( 'bar' , []),
816
816
]);
817
817
818
818
final unknownOptionKey = PollEventSubmessage .optionKey (
@@ -835,7 +835,7 @@ void main() {
835
835
836
836
test ('ignore invalid vote op' , () async {
837
837
message = await preparePollMessage (
838
- options : [eg. pollOption (text : 'foo' , voters : [])]);
838
+ optionVoterIdsPairs : [( 'foo' , [])]);
839
839
checkPoll (message).options.deepEquals ([conditionPollOption ('foo' )]);
840
840
await store.handleEvent (eg.submessageEvent (message.id, eg.otherUser.userId,
841
841
content: PollVoteEventSubmessage (
0 commit comments