@mks2508/telegram-message-builder 0.3.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -84,12 +84,12 @@ describe("Integration Tests", () => {
84
84
  expect(message.text).toContain("• ✅ Verified");
85
85
  expect(message.text).toContain("View Full Profile");
86
86
  expect(message.text).toContain("tg://user?id=123456");
87
- expect(message.parse_mode).toBe("html");
87
+ expect(message.parse_mode).toBe("HTML");
88
88
  });
89
89
 
90
90
  it("should build same message in Markdown mode", () => {
91
91
  const message = TelegramMessageBuilder.text()
92
- .setParseMode("markdown")
92
+ .setParseMode("Markdown")
93
93
  .title("👤 User Profile")
94
94
  .newline()
95
95
  .section("Personal Information")
@@ -100,12 +100,12 @@ describe("Integration Tests", () => {
100
100
  expect(message.text).toContain("*👤 User Profile*");
101
101
  expect(message.text).toContain("Name: *John Doe*");
102
102
  expect(message.text).toContain("Status: _Active_");
103
- expect(message.parse_mode).toBe("markdown");
103
+ expect(message.parse_mode).toBe("Markdown");
104
104
  });
105
105
 
106
106
  it("should build same message in MarkdownV2 mode", () => {
107
107
  const message = TelegramMessageBuilder.text()
108
- .setParseMode("markdownv2")
108
+ .setParseMode("MarkdownV2")
109
109
  .title("👤 User Profile")
110
110
  .newline()
111
111
  .section("Personal Information")
@@ -118,7 +118,7 @@ describe("Integration Tests", () => {
118
118
  expect(message.text).toContain("Name: *John Doe*");
119
119
  expect(message.text).toContain("Status: _Active_");
120
120
  expect(message.text).toContain("Level: __Premium__");
121
- expect(message.parse_mode).toBe("markdownv2");
121
+ expect(message.parse_mode).toBe("MarkdownV2");
122
122
  });
123
123
 
124
124
  it("should build product listing message", () => {
@@ -207,28 +207,28 @@ describe("Integration Tests", () => {
207
207
  describe("Cross-Mode Message Consistency", () => {
208
208
  it("should produce equivalent messages in all three modes", () => {
209
209
  const htmlMessage = TelegramMessageBuilder.text()
210
- .setParseMode("html")
210
+ .setParseMode("HTML")
211
211
  .title("Welcome")
212
212
  .line("Status", "Active", { bold: true })
213
213
  .link("Click here", "https://example.com")
214
214
  .build();
215
215
 
216
216
  const mdMessage = TelegramMessageBuilder.text()
217
- .setParseMode("markdown")
217
+ .setParseMode("Markdown")
218
218
  .title("Welcome")
219
219
  .line("Status", "Active", { bold: true })
220
220
  .link("Click here", "https://example.com")
221
221
  .build();
222
222
 
223
223
  const mdv2Message = TelegramMessageBuilder.text()
224
- .setParseMode("markdownv2")
224
+ .setParseMode("MarkdownV2")
225
225
  .title("Welcome")
226
226
  .line("Status", "Active", { bold: true })
227
227
  .link("Click here", "https://example.com")
228
228
  .build();
229
229
 
230
230
  // HTML mode
231
- expect(htmlMessage.parse_mode).toBe("html");
231
+ expect(htmlMessage.parse_mode).toBe("HTML");
232
232
  expect(htmlMessage.text).toContain("<b>Welcome</b>");
233
233
  expect(htmlMessage.text).toContain("Status: <b>Active</b>");
234
234
  expect(htmlMessage.text).toContain(
@@ -236,13 +236,13 @@ describe("Integration Tests", () => {
236
236
  );
237
237
 
238
238
  // Markdown mode
239
- expect(mdMessage.parse_mode).toBe("markdown");
239
+ expect(mdMessage.parse_mode).toBe("Markdown");
240
240
  expect(mdMessage.text).toContain("*Welcome*");
241
241
  expect(mdMessage.text).toContain("Status: *Active*");
242
242
  expect(mdMessage.text).toContain("[Click here](https://example.com)");
243
243
 
244
244
  // MarkdownV2 mode
245
- expect(mdv2Message.parse_mode).toBe("markdownv2");
245
+ expect(mdv2Message.parse_mode).toBe("MarkdownV2");
246
246
  expect(mdv2Message.text).toContain("*Welcome*");
247
247
  expect(mdv2Message.text).toContain("Status: *Active*");
248
248
  expect(mdv2Message.text).toContain("[Click here](https://example.com)");
@@ -307,7 +307,7 @@ describe("Integration Tests", () => {
307
307
 
308
308
  it("should handle special characters in MarkdownV2", () => {
309
309
  const message = TelegramMessageBuilder.text()
310
- .setParseMode("markdownv2")
310
+ .setParseMode("MarkdownV2")
311
311
  .title("Test")
312
312
  .text("Text with * and _ and ~")
313
313
  .build();
@@ -360,7 +360,7 @@ describe("Integration Tests", () => {
360
360
  it("should handle empty builder", () => {
361
361
  const message = TelegramMessageBuilder.text().build();
362
362
  expect(message.text).toBe("");
363
- expect(message.parse_mode).toBe("html");
363
+ expect(message.parse_mode).toBe("HTML");
364
364
  });
365
365
 
366
366
  it("should handle message with only newlines", () => {
@@ -77,17 +77,17 @@ describe("Media Integration Tests", () => {
77
77
 
78
78
  const html = TelegramMediaBuilder.photo("photo.jpg")
79
79
  .caption(captionText)
80
- .setParseMode("html")
80
+ .setParseMode("HTML")
81
81
  .build();
82
82
 
83
83
  const md = TelegramMediaBuilder.photo("photo.jpg")
84
84
  .caption(captionText)
85
- .setParseMode("markdown")
85
+ .setParseMode("Markdown")
86
86
  .build();
87
87
 
88
88
  const mdv2 = TelegramMediaBuilder.photo("photo.jpg")
89
89
  .caption(captionText)
90
- .setParseMode("markdownv2")
90
+ .setParseMode("MarkdownV2")
91
91
  .build();
92
92
 
93
93
  // HTML mode: * and _ are NOT special, should be left as-is
@@ -99,9 +99,9 @@ describe("Media Integration Tests", () => {
99
99
  expect(mdv2.caption).toContain("\\*");
100
100
  expect(mdv2.caption).toContain("\\_");
101
101
 
102
- expect(html.parse_mode).toBe("html");
103
- expect(md.parse_mode).toBe("markdown");
104
- expect(mdv2.parse_mode).toBe("markdownv2");
102
+ expect(html.parse_mode).toBe("HTML");
103
+ expect(md.parse_mode).toBe("Markdown");
104
+ expect(mdv2.parse_mode).toBe("MarkdownV2");
105
105
  });
106
106
 
107
107
  it("should handle HTML tags in captions correctly", () => {
@@ -109,7 +109,7 @@ describe("Media Integration Tests", () => {
109
109
 
110
110
  const html = TelegramMediaBuilder.photo("photo.jpg")
111
111
  .caption(caption)
112
- .setParseMode("html")
112
+ .setParseMode("HTML")
113
113
  .build();
114
114
 
115
115
  // HTML mode should escape tags
@@ -124,7 +124,7 @@ describe("Media Integration Tests", () => {
124
124
  .caption(
125
125
  "📱 iPhone 15 Pro - $999\n\n✅ 256GB Storage\n✅ Titanium Design\n✅ A17 Pro Chip",
126
126
  )
127
- .setParseMode("markdown")
127
+ .setParseMode("Markdown")
128
128
  .build();
129
129
 
130
130
  const keyboard = TelegramKeyboardBuilder.inline()
@@ -135,7 +135,7 @@ describe("Media Integration Tests", () => {
135
135
 
136
136
  expect(media.type).toBe("photo");
137
137
  expect(media.caption).toContain("iPhone 15 Pro");
138
- expect(media.parse_mode).toBe("markdown");
138
+ expect(media.parse_mode).toBe("Markdown");
139
139
  expect(keyboard.inline_keyboard?.[0]?.length).toBe(3);
140
140
  });
141
141
 
@@ -292,7 +292,7 @@ describe("Media Integration Tests", () => {
292
292
  const caption = "Text with *bold* and _italic_ and ~strike~";
293
293
  const media = TelegramMediaBuilder.photo("photo.jpg")
294
294
  .caption(caption)
295
- .setParseMode("markdownv2")
295
+ .setParseMode("MarkdownV2")
296
296
  .build();
297
297
 
298
298
  expect(media.caption).toContain("\\*");
@@ -347,7 +347,7 @@ describe("Media Integration Tests", () => {
347
347
  it("should maintain type safety through build chain", () => {
348
348
  const media = TelegramMediaBuilder.photo("photo.jpg")
349
349
  .caption("Test")
350
- .setParseMode("html")
350
+ .setParseMode("HTML")
351
351
  .setOption("protect_content", true)
352
352
  .build();
353
353
 
@@ -7,7 +7,7 @@
7
7
  /**
8
8
  * Parse mode for Telegram messages
9
9
  */
10
- export type ParseMode = "html" | "markdown" | "markdownv2";
10
+ export type ParseMode = "HTML" | "Markdown" | "MarkdownV2";
11
11
 
12
12
  /**
13
13
  * Format options for inline formatting
package/src/types.test.ts CHANGED
@@ -14,25 +14,25 @@ import * as fmt from "../src";
14
14
 
15
15
  describe("Type Validation Tests", () => {
16
16
  describe("ParseMode Type", () => {
17
- it("should accept 'html' as valid ParseMode", () => {
18
- const mode: ParseMode = "html";
19
- expect(mode).toBe("html");
17
+ it("should accept 'HTML' as valid ParseMode", () => {
18
+ const mode: ParseMode = "HTML";
19
+ expect(mode).toBe("HTML");
20
20
  });
21
21
 
22
- it("should accept 'markdown' as valid ParseMode", () => {
23
- const mode: ParseMode = "markdown";
24
- expect(mode).toBe("markdown");
22
+ it("should accept 'Markdown' as valid ParseMode", () => {
23
+ const mode: ParseMode = "Markdown";
24
+ expect(mode).toBe("Markdown");
25
25
  });
26
26
 
27
- it("should accept 'markdownv2' as valid ParseMode", () => {
28
- const mode: ParseMode = "markdownv2";
29
- expect(mode).toBe("markdownv2");
27
+ it("should accept 'MarkdownV2' as valid ParseMode", () => {
28
+ const mode: ParseMode = "MarkdownV2";
29
+ expect(mode).toBe("MarkdownV2");
30
30
  });
31
31
 
32
32
  it("should reject invalid ParseMode values at compile time", () => {
33
33
  // @ts-expect-error - Invalid ParseMode
34
34
  const invalidMode: ParseMode = "invalid";
35
- expect(invalidMode).not.toBe("html");
35
+ expect(invalidMode).not.toBe("HTML");
36
36
  });
37
37
  });
38
38
 
@@ -40,17 +40,17 @@ describe("Type Validation Tests", () => {
40
40
  it("should create valid TelegramMessage structure", () => {
41
41
  const message: ITelegramMessage = {
42
42
  text: "Test message",
43
- parse_mode: "html",
43
+ parse_mode: "HTML",
44
44
  };
45
45
 
46
46
  expect(message.text).toBe("Test message");
47
- expect(message.parse_mode).toBe("html");
47
+ expect(message.parse_mode).toBe("HTML");
48
48
  });
49
49
 
50
50
  it("should accept optional properties in TelegramMessage", () => {
51
51
  const message: ITelegramMessage = {
52
52
  text: "Test",
53
- parse_mode: "markdown",
53
+ parse_mode: "Markdown",
54
54
  disable_web_page_preview: true,
55
55
  disable_notification: false,
56
56
  protect_content: true,
@@ -64,7 +64,7 @@ describe("Type Validation Tests", () => {
64
64
  it("should allow extra properties for Telegram Bot API options", () => {
65
65
  const message: ITelegramMessage = {
66
66
  text: "Test",
67
- parse_mode: "html",
67
+ parse_mode: "HTML",
68
68
  reply_to_message_id: 123,
69
69
  allow_sending_without_reply: true,
70
70
  };
@@ -386,13 +386,13 @@ describe("Type Validation Tests", () => {
386
386
  .link("Link", "url")
387
387
  .mention(123)
388
388
  .hashtag("tag")
389
- .setParseMode("html")
389
+ .setParseMode("HTML")
390
390
  .setOption("key", "value")
391
391
  .setOptions({ key2: "value2" })
392
392
  .build();
393
393
 
394
394
  expect(message.text).toBeDefined();
395
- expect(message.parse_mode).toBe("html");
395
+ expect(message.parse_mode).toBe("HTML");
396
396
  });
397
397
 
398
398
  it("should allow method chaining on TelegramKeyboardBuilder (inline)", () => {
@@ -429,7 +429,7 @@ describe("Type Validation Tests", () => {
429
429
 
430
430
  describe("Type Guards and Validation", () => {
431
431
  it("should validate parse_mode at runtime", () => {
432
- const validModes: ParseMode[] = ["html", "markdown", "markdownv2"];
432
+ const validModes: ParseMode[] = ["HTML", "Markdown", "MarkdownV2"];
433
433
 
434
434
  validModes.forEach((mode) => {
435
435
  const builder = TelegramMessageBuilder.text().setParseMode(mode);
@@ -444,7 +444,7 @@ describe("Type Validation Tests", () => {
444
444
  expect(message).toBeDefined();
445
445
  expect(typeof message.text).toBe("string");
446
446
  expect(typeof message.parse_mode).toBe("string");
447
- expect(["html", "markdown", "markdownv2"]).toContain(message.parse_mode);
447
+ expect(["HTML", "Markdown", "MarkdownV2"]).toContain(message.parse_mode);
448
448
  });
449
449
 
450
450
  it("should validate keyboard structure", () => {