-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tebbe Ubben
committed
Jun 23, 2024
1 parent
55b589b
commit 827b1fd
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...re.package/TCTCMessageTests.class/instance/testPollMessageCorrectlyConstructedFromJson.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
testing | ||
testPollMessageCorrectlyConstructedFromJson | ||
|
||
| pollMessageEvent chat pollMessage | | ||
|
||
chat := TCTMMocks mockPrivateChat. | ||
pollMessageEvent := TCTMMocks mockPollMessageJsonFrom: chat id. | ||
pollMessage := TCCMessage newFromMessageEvent: pollMessageEvent in: chat with: self core. | ||
|
||
self assert: pollMessage allowsMultipleAnswers equals: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/TelegramClientTests-Misc.package/TCTMMocks.class/class/mockPollMessageJsonFrom..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
message - json | ||
mockPollMessageJsonFrom: aChatId | ||
"@linter-ignore" | ||
|
||
^ (JsonObject newFrom: { | ||
'@type' -> 'message'. | ||
'id' -> self mockMessageId. | ||
'chat_id' -> aChatId. | ||
'sender_id' -> (JsonObject newFrom: { | ||
'@type' -> 'messageSenderUser'. | ||
'user_id' -> self mockUser1 id | ||
}). | ||
'content' -> (JsonObject newFrom: { | ||
'@type' -> 'messagePoll'. | ||
'poll' -> (JsonObject newFrom: { | ||
'@type' -> 'poll'. | ||
'close_date' -> 0. | ||
'id' -> 1. | ||
'is_anonymous' -> false. | ||
'is_closed' -> false. | ||
'open_period' -> false. | ||
'question' -> 'Question'. | ||
'total_voter_count' -> 0. | ||
'type' -> (JsonObject newFrom: { | ||
'@type' -> 'pollTypeRegular'. | ||
'allow_multiple_answers' -> true. | ||
}). | ||
'options' -> self mockPollOptionsJson. | ||
}). | ||
}). | ||
'is_outgoing' -> false. | ||
'date' -> self mockMessageTimestamp | ||
}) |
11 changes: 11 additions & 0 deletions
11
...Mocks.class/class/mockPollOptionJson.isBeingChosen.isChosen.votePercentage.voterCount..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
message - json | ||
mockPollOptionJson: text isBeingChosen: beingChosen isChosen: chosen votePercentage: percentage voterCount: count | ||
|
||
^ (JsonObject newFrom: { | ||
'@type' -> 'pollOption'. | ||
'is_being_chosen' -> beingChosen. | ||
'is_chosen' -> chosen. | ||
'text' -> text. | ||
'vote_percentage' -> percentage. | ||
'voter_count' -> count. | ||
}) |
10 changes: 10 additions & 0 deletions
10
packages/TelegramClientTests-Misc.package/TCTMMocks.class/class/mockPollOptionsJson.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
message - json | ||
mockPollOptionsJson | ||
|
||
| options | | ||
options := Array new: 3. | ||
options at: 1 put: (self mockPollOptionJson: 'Option 1' isBeingChosen: false isChosen: true votePercentage: 50 voterCount: 2). | ||
options at: 2 put: (self mockPollOptionJson: 'Option 2' isBeingChosen: false isChosen: false votePercentage: 25 voterCount: 1). | ||
options at: 3 put: (self mockPollOptionJson: 'Option 3' isBeingChosen: false isChosen: false votePercentage: 25 voterCount: 1). | ||
|
||
^ options. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters