+ err := newBotAPI(server.URL, testBotToken).SendMessage(t.Context(), testOwner, "a link", []botEntity{
+ {
+ Type: "text_link",
+ Offset: 2,
+ Length: 4,
+ URL: "https://example.com",
+ },
+ })
+ require.NoError(t, err)
+
+ require.Equal(t, []any{
+ map[string]any{
+ "type": "text_link",
+ "offset": float64(2),
+ "length": float64(4),
+ "url": "https://example.com",
+ },
+ }, server.Calls()[0].params["entities"])
+}
+
+func TestSendRichMessageSendsTheMarkdownUnchanged(t *testing.T) {
+ server := newFakeBot(t)
+ markdown := "| a | b |\n|---|---|\n| **1** | `2` |"
+ err := newBotAPI(server.URL, testBotToken).SendRichMessage(t.Context(), testOwner, markdown)
+ require.NoError(t, err)
+
+ call := server.Calls()[0]
+ require.Equal(t, "sendRichMessage", call.method)
+ require.Equal(t, map[string]any{
+ "chat_id": float64(testOwner),
+ "rich_message": map[string]any{
+ "markdown": markdown,
+ },
+ }, call.params)
+}
+
+func TestSendCallsTimeOutOnAStalledConnection(t *testing.T) {
+ testCases := []struct {
+ method string
+ send func(ctx context.Context, api *botAPI) error
+ }{
+ {
+ method: "sendMessage",
+ send: func(ctx context.Context, api *botAPI) error {
+ return api.SendMessage(ctx, testOwner, "hi", nil)
+ },
+ },
+ {
+ method: "sendRichMessage",
+ send: func(ctx context.Context, api *botAPI) error {
+ return api.SendRichMessage(ctx, testOwner, "hi")
+ },
+ },