Skip to content

Commit

Permalink
added Construction and Identification tests for video, sticker and do…
Browse files Browse the repository at this point in the history
…cument messages
  • Loading branch information
jkubuni committed Jun 23, 2024
1 parent 68554e3 commit 161b1d9
Show file tree
Hide file tree
Showing 28 changed files with 277 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"newFrom:" : "JK 5/31/2024 11:40" },
"newFrom:" : "JK 6/23/2024 11:47" },
"instance" : {
"asSnippet" : "RK 6/26/2021 11:37",
"asText" : "rgw 5/12/2022 14:28",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"newFrom:" : "AH 6/21/2024 14:02" },
"newFrom:" : "JK 6/23/2024 11:52" },
"instance" : {
"asSnippet" : "AH 6/21/2024 13:54",
"asText" : "AH 6/21/2024 13:54",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"class" : {
"extractPathFrom:" : " 6/22/2024 13:42:57",
"imageFormFrom:" : " 6/22/2024 13:42:57",
"newWith:" : " 6/22/2024 13:42:57" },
"extractPathFrom:" : "6/22/2024 13:42:57",
"imageFormFrom:" : "6/22/2024 13:42:57",
"newWith:" : "6/22/2024 13:42:57" },
"instance" : {
"core" : " 6/22/2024 13:42:57",
"core:" : " 6/22/2024 13:42:57",
"getFormFor:" : " 6/22/2024 13:42:57",
"getFormPromiseFor:" : " 6/22/2024 13:42:57",
"requestImageFor:with:" : " 6/22/2024 13:42:57" } }
"core" : "6/22/2024 13:42:57",
"core:" : "6/22/2024 13:42:57",
"getFormFor:" : "6/22/2024 13:42:57",
"getFormPromiseFor:" : "6/22/2024 13:42:57",
"requestImageFor:with:" : "6/22/2024 13:42:57" } }
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"class" : {
"newAnimatedStickerFrom:" : "JK 5/31/2024 11:36",
"newFrom:" : "JK 5/31/2024 11:11" },
"newFrom:" : "JK 6/23/2024 11:39" },
"instance" : {
"asSnippet" : "JK 5/16/2024 16:00",
"asText" : "JK 5/16/2024 16:00",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"class" : {
"extractPathFrom:" : " 6/22/2024 13:42:57",
"extractPathFrom:" : "6/22/2024 13:42:57",
"imageFormFrom:" : "JK 6/21/2024 13:46",
"newWith:" : "JK 6/20/2024 22:18",
"stickerFormFrom:" : " 6/22/2024 13:42:57" },
"stickerFormFrom:" : "6/22/2024 13:42:57" },
"instance" : {
"core" : " 6/22/2024 13:42:57",
"core:" : " 6/22/2024 13:42:57",
"core" : "6/22/2024 13:42:57",
"core:" : "6/22/2024 13:42:57",
"downloadStickerSet:" : "JK 6/19/2024 11:33",
"getFormFor:" : " 6/22/2024 13:42:57",
"getFormPromiseFor:" : " 6/22/2024 13:42:57",
"getFormFor:" : "6/22/2024 13:42:57",
"getFormPromiseFor:" : "6/22/2024 13:42:57",
"getInstalledStickers" : "JK 6/5/2024 11:37",
"loadStickerIds" : "JK 6/20/2024 23:39",
"requestStickerFor:with:" : "JK 5/16/2024 21:40",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"class" : {
"newFrom:" : "JK 6/12/2024 11:28" },
"newFrom:" : "JK 6/23/2024 11:14" },
"instance" : {
"asSnippet" : "JK 6/12/2024 11:31",
"asText" : "TR 6/20/2021 10:41",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"class" : {
"extractPathFrom:" : " 6/22/2024 13:42:57",
"imageFormFrom:" : " 6/22/2024 13:42:57" },
"extractPathFrom:" : "6/22/2024 13:42:57",
"imageFormFrom:" : "6/22/2024 13:42:57" },
"instance" : {
"getFormFor:" : " 6/22/2024 13:42:57",
"getFormPromiseFor:" : " 6/22/2024 13:42:57",
"getFormFor:" : "6/22/2024 13:42:57",
"getFormPromiseFor:" : "6/22/2024 13:42:57",
"getVideoFor:" : "JK 6/12/2024 19:48",
"getVideoPromiseFor:" : "JK 6/12/2024 19:56" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
testAnimatedStickerMessageCorrectlyConstructedFromJson

| stickerMessageEvent chat stickerMessage |

chat := TCTMMocks mockPrivateChat.
stickerMessageEvent := TCTMMocks mockAnimatedStickerMessageJsonFrom: chat id.
stickerMessage := TCCMessage newFromMessageEvent: stickerMessageEvent in: chat with: self core.

self assert: TCTMMocks mockValidEmoji equals: stickerMessage text.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
testAnimatedStickerMessageTypeIdentifiedCorrectly

| stickerMessageEvent chat stickerMessage |

chat := TCTMMocks mockPrivateChat.
stickerMessageEvent := TCTMMocks mockAnimatedStickerMessageJsonFrom: chat id.
stickerMessage := TCCMessage newFromMessageEvent: stickerMessageEvent in: chat with: self core.

self assert: TCCAnimatedStickerMessage equals: stickerMessage class.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
testDocumentMessageCorrectlyConstructedFromJson

| documentMessageEvent chat documentMessage |

chat := TCTMMocks mockPrivateChat.
documentMessageEvent := TCTMMocks mockDocumentMessageJsonFrom: chat id.
documentMessage := TCCMessage newFromMessageEvent: documentMessageEvent in: chat with: self core.

self assert: TCTMMocks mockDocumentFileName equals: documentMessage filename.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
testDocumentMessageTypeIdentifiedCorrectly

| documentMessageEvent chat documentMessage |

chat := TCTMMocks mockPrivateChat.
documentMessageEvent := TCTMMocks mockDocumentMessageJsonFrom: chat id.
documentMessage := TCCMessage newFromMessageEvent: documentMessageEvent in: chat with: self core.

self assert: TCCDocumentMessage equals: documentMessage class.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
testing
testStaticStickerMessageCorrectlyContructedFromJson

| stickerMessageEvent chat stickerMessage |

chat := TCTMMocks mockPrivateChat.
stickerMessageEvent := TCTMMocks mockStaticStickerMessageJsonFrom: chat id.
stickerMessage := TCCMessage newFromMessageEvent: stickerMessageEvent in: chat with: self core.

self assert: TCTMMocks mockStickerId equals: stickerMessage stickerId.
self assert: TCTMMocks mockStickerWidth equals: stickerMessage width.
self assert: TCTMMocks mockStickerHeight equals: stickerMessage height.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
testStaticStickerMessageTypeIdentifiedCorrectly

| stickerMessageEvent chat stickerMessage |

chat := TCTMMocks mockPrivateChat.
stickerMessageEvent := TCTMMocks mockStaticStickerMessageJsonFrom: chat id.
stickerMessage := TCCMessage newFromMessageEvent: stickerMessageEvent in: chat with: self core.

self assert: TCCStickerMessage equals: stickerMessage class.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
testing
testVideoMessageCorrectlyConstructedFromJson

| videoMessageEvent chat videoMessage |

chat := TCTMMocks mockPrivateChat.
videoMessageEvent := TCTMMocks mockVideoMessageJsonFrom: chat id.
videoMessage := TCCMessage newFromMessageEvent: videoMessageEvent in: chat with: self core.

self assert: TCTMMocks mockText equals: videoMessage caption.
self assert: videoMessage hasCaption.
self assert: TCTMMocks mockImageId equals: videoMessage thumbnailId.
self assert: TCTMMocks mockPhotoHeight equals: videoMessage height.
self assert: TCTMMocks mockPhotoWidth equals: videoMessage width.
self assert: TCTMMocks mockVideoId equals: videoMessage videoId.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
testing
testVideoMessageTypeIdentifiedCorrectly

| videoMessageEvent chat videoMessage |

chat := TCTMMocks mockPrivateChat.
videoMessageEvent := TCTMMocks mockVideoMessageJsonFrom: chat id.
videoMessage := TCCMessage newFromMessageEvent: videoMessageEvent in: chat with: self core.

self assert: TCCVideoMessage equals: videoMessage class.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"class" : {
},
"instance" : {
"testAnimatedStickerMessageCorrectlyConstructedFromJson" : "JK 6/23/2024 11:49",
"testAnimatedStickerMessageTypeIdentifiedCorrectly" : "JK 6/23/2024 11:45",
"testDocumentMessageCorrectlyConstructedFromJson" : "JK 6/23/2024 12:01",
"testDocumentMessageTypeIdentifiedCorrectly" : "JK 6/23/2024 11:55",
"testMessageAddMembersCorrectlyConstructedFromJson" : "ek 8/5/2022 15:07",
"testMessageCorrectlyConstructedFromJson" : "js 7/31/2022 10:28",
"testMessageDeleteMemberCorrectlyConstructedFromJson" : "ek 8/5/2022 15:08",
Expand All @@ -14,8 +18,12 @@
"testMessageWithMessageSenderChatCorrectlyConstructedFromJson" : "js 7/31/2022 10:29",
"testNotSupportedMessageTypeIdentifiedCorrectly" : "js 7/31/2022 10:29",
"testPhotoMessageCorrectlyConstructedFromJson" : "js 7/31/2022 10:29",
"testPhotoMessageTypeIdentifiedCorrectly" : "js 7/31/2022 10:29",
"testPhotoMessageTypeIdentifiedCorrectly" : "JK 6/23/2024 11:26",
"testSenderNameInChannelMessage" : "tom.richter 7/25/2021 11:36",
"testSenderNameInNonChannelMessage" : "per 7/17/2021 16:13",
"testStaticStickerMessageCorrectlyContructedFromJson" : "JK 6/23/2024 11:43",
"testStaticStickerMessageTypeIdentifiedCorrectly" : "JK 6/23/2024 11:30",
"testTextMessageCorrectlyConstructedFromJson" : "js 7/31/2022 10:30",
"testTextMessageTypeIdentifiedCorrectly" : "js 7/31/2022 10:30" } }
"testTextMessageTypeIdentifiedCorrectly" : "js 7/31/2022 10:30",
"testVideoMessageCorrectlyConstructedFromJson" : "JK 6/23/2024 11:12",
"testVideoMessageTypeIdentifiedCorrectly" : "JK 6/23/2024 11:24" } }
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
message - json
mockAnimatedStickerMessageJsonFrom: 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' -> 'messageSticker'.
'sticker' -> (JsonObject newFrom: {
'is_animated' -> true.
'height' -> self mockStickerHeight.
'width' -> self mockStickerWidth.
'sticker' -> (JsonObject newFrom: {
'id' -> self mockStickerId
}).
'emoji' -> self mockValidEmoji
}).
}).
'is_outgoing' -> false.
'date' -> self mockMessageTimestamp
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message - json
mockDocumentFileName

^ 'test_document.pdf'
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
message - json
mockDocumentMessageJsonFrom: 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' -> 'messageDocument'.
'caption' -> (JsonObject newFrom: {
'text' -> self mockText
}).
'document' -> (JsonObject newFrom: {
'file_name' -> self mockDocumentFileName.
'thumbnail' -> (JsonObject newFrom:{
'file' -> (JsonObject newFrom: {
'id' -> self mockImageId
}).
'width' -> self mockPhotoWidth.
'height' -> self mockPhotoHeight
}).
}).
}).
'is_outgoing' -> false.
'date' -> self mockMessageTimestamp
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
message - json
mockStaticStickerMessageJsonFrom: 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' -> 'messageSticker'.
'sticker' -> (JsonObject newFrom: {
'is_animated' -> false.
'height' -> self mockStickerHeight.
'width' -> self mockStickerWidth.
'sticker' -> (JsonObject newFrom: {
'id' -> self mockStickerId
}).
}).
}).
'is_outgoing' -> false.
'date' -> self mockMessageTimestamp
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image
mockStickerHeight

^ 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image
mockStickerId

^ 24
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image
mockStickerWidth

^ 100
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message
mockVideoHeight

^ 265
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image
mockVideoId

^ 42
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
message - json
mockVideoMessageJsonFrom: 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' -> 'messageVideo'.
'caption' -> (JsonObject newFrom: {
'text' -> self mockText
}).
'video' -> (JsonObject newFrom: {
'height' -> self mockVideoHeight.
'width' -> self mockVideoWidth.
'thumbnail' -> (JsonObject newFrom:{
'file' -> (JsonObject newFrom: {
'id' -> self mockImageId
}).
'width' -> self mockPhotoWidth.
'height' -> self mockPhotoHeight
}).
'video' -> (JsonObject newFrom:{
'id' -> self mockVideoId
}).
}).
}).
'is_outgoing' -> false.
'date' -> self mockMessageTimestamp
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message
mockVideoWidth

^ 521
Loading

0 comments on commit 161b1d9

Please sign in to comment.