@nimee/shared-types 1.0.204 → 1.0.205

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.
@@ -0,0 +1,232 @@
1
+ import { getTranslation } from "../src/common/translations";
2
+ import { ILanguageEnum } from "../src/common/common";
3
+
4
+ describe("Translations", () => {
5
+ describe("getTranslation", () => {
6
+ it("should return English translation for order confirmation", () => {
7
+ const params = {
8
+ fname: "John",
9
+ eventName: "Summer Concert",
10
+ date: "01/01/2024",
11
+ ticketsLink: "https://example.com/tickets",
12
+ };
13
+
14
+ const translation = getTranslation("orderConfirmation", ILanguageEnum.en, params);
15
+
16
+ expect(translation).toBe(
17
+ "Dear John, your reservation for the Summer Concert on 01/01/2024 has been confirmed. Tickets and event details, awaits here: https://example.com/tickets"
18
+ );
19
+ });
20
+
21
+ it("should return Hebrew translation for order confirmation", () => {
22
+ const params = {
23
+ fname: "ישראל",
24
+ eventName: "קונצרט קיץ",
25
+ date: "01/01/2024",
26
+ ticketsLink: "https://example.com/tickets",
27
+ };
28
+
29
+ const translation = getTranslation("orderConfirmation", ILanguageEnum.he, params);
30
+
31
+ expect(translation).toBe(
32
+ "שלום ישראל, הזמנתך לאירוע קונצרט קיץ בתאריך 01/01/2024 נקלטה במערכת ואושרה. כרטיסים ופרטים מלאים בלינק: https://example.com/tickets"
33
+ );
34
+ });
35
+
36
+ it("should return Arabic translation for order confirmation", () => {
37
+ const params = {
38
+ fname: "أحمد",
39
+ eventName: "حفلة الصيف",
40
+ date: "01/01/2024",
41
+ ticketsLink: "https://example.com/tickets",
42
+ };
43
+
44
+ const translation = getTranslation("orderConfirmation", ILanguageEnum.ar, params);
45
+
46
+ expect(translation).toBe(
47
+ "عزيزي أحمد، تم تأكيد حجزك لـ حفلة الصيف في 01/01/2024. تنتظرك التذاكر وتفاصيل الحدث هنا: https://example.com/tickets"
48
+ );
49
+ });
50
+
51
+ it("should handle missing parameters gracefully", () => {
52
+ const params = {
53
+ fname: "John",
54
+ eventName: "Summer Concert",
55
+ // date and ticketsLink are missing
56
+ };
57
+
58
+ const translation = getTranslation("orderConfirmation", ILanguageEnum.en, params);
59
+
60
+ expect(translation).toBe(
61
+ "Dear John, your reservation for the Summer Concert on {date} has been confirmed. Tickets and event details, awaits here: {ticketsLink}"
62
+ );
63
+ });
64
+
65
+ it("should handle all supported languages", () => {
66
+ const params = {
67
+ fname: "Test",
68
+ eventName: "Test Event",
69
+ date: "01/01/2024",
70
+ ticketsLink: "https://example.com/tickets",
71
+ };
72
+
73
+ // Test that all languages return a non-empty string
74
+ Object.values(ILanguageEnum).forEach((language) => {
75
+ const translation = getTranslation("orderConfirmation", language, params);
76
+ expect(translation).toBeTruthy();
77
+ expect(typeof translation).toBe("string");
78
+ expect(translation.length).toBeGreaterThan(0);
79
+ });
80
+ });
81
+
82
+ it("should handle special characters in parameters", () => {
83
+ const params = {
84
+ fname: "John & Jane",
85
+ eventName: "Summer & Winter Concert",
86
+ date: "01/01/2024",
87
+ ticketsLink: "https://example.com/tickets?param=value&other=123",
88
+ };
89
+
90
+ const translation = getTranslation("orderConfirmation", ILanguageEnum.en, params);
91
+
92
+ expect(translation).toBe(
93
+ "Dear John & Jane, your reservation for the Summer & Winter Concert on 01/01/2024 has been confirmed. Tickets and event details, awaits here: https://example.com/tickets?param=value&other=123"
94
+ );
95
+ });
96
+
97
+ it("should handle empty strings in parameters", () => {
98
+ const params = {
99
+ fname: "",
100
+ eventName: "Summer Concert",
101
+ date: "01/01/2024",
102
+ ticketsLink: "",
103
+ };
104
+
105
+ const translation = getTranslation("orderConfirmation", ILanguageEnum.en, params);
106
+
107
+ expect(translation).toBe(
108
+ "Dear , your reservation for the Summer Concert on 01/01/2024 has been confirmed. Tickets and event details, awaits here: "
109
+ );
110
+ });
111
+ });
112
+
113
+ describe("bookingConfirmationSubject", () => {
114
+ it("should return correct English translation", () => {
115
+ const translation = getTranslation("bookingConfirmationSubject", ILanguageEnum.en, {});
116
+ expect(translation).toBe("Your booking has been successfully confirmed");
117
+ });
118
+
119
+ it("should return correct Hebrew translation", () => {
120
+ const translation = getTranslation("bookingConfirmationSubject", ILanguageEnum.he, {});
121
+ expect(translation).toBe("הזמנתך התקבלה בהצלחה");
122
+ });
123
+
124
+ it("should return correct Arabic translation", () => {
125
+ const translation = getTranslation("bookingConfirmationSubject", ILanguageEnum.ar, {});
126
+ expect(translation).toBe("تم تأكيد حجزك بنجاح");
127
+ });
128
+
129
+ it("should return valid translations for all supported languages", () => {
130
+ Object.values(ILanguageEnum).forEach((language) => {
131
+ const translation = getTranslation("bookingConfirmationSubject", language, {});
132
+ expect(translation).toBeTruthy();
133
+ expect(typeof translation).toBe("string");
134
+ expect(translation.length).toBeGreaterThan(0);
135
+ });
136
+ });
137
+ });
138
+
139
+ describe("orderWaitingForApproval", () => {
140
+ it("should return correct English translation for part 1", () => {
141
+ const translation = getTranslation("orderWaitingForApproval1", ILanguageEnum.en, {});
142
+ expect(translation).toBe("Your ticket request has been received.");
143
+ });
144
+
145
+ it("should return correct Hebrew translation for part 1", () => {
146
+ const translation = getTranslation("orderWaitingForApproval1", ILanguageEnum.he, {});
147
+ expect(translation).toBe("הזמנתך התקבלה אבל כרטיסך לא חוייב");
148
+ });
149
+
150
+ it("should return correct Arabic translation for part 1", () => {
151
+ const translation = getTranslation("orderWaitingForApproval1", ILanguageEnum.ar, {});
152
+ expect(translation).toBe("تم استلام طلبك ولكن لم يتم خصم تذكرتك وهي في انتظار الموافقة وفقًا لعدد التذاكر ووفقًا للشروط");
153
+ });
154
+
155
+ it("should return valid translations for all supported languages for part 1", () => {
156
+ Object.values(ILanguageEnum).forEach((language) => {
157
+ const translation = getTranslation("orderWaitingForApproval1", language, {});
158
+ expect(translation).toBeTruthy();
159
+ expect(typeof translation).toBe("string");
160
+ expect(translation.length).toBeGreaterThan(0);
161
+ });
162
+ });
163
+
164
+ it("should return correct English translation for part 2", () => {
165
+ const translation = getTranslation("orderWaitingForApproval2", ILanguageEnum.en, {});
166
+ expect(translation).toBe("The request is pending review by the club team.");
167
+ });
168
+
169
+ it("should return correct English translation for part 3", () => {
170
+ const translation = getTranslation("orderWaitingForApproval3", ILanguageEnum.en, {});
171
+ expect(translation).toBe("No charges will be made until the reservation is approved. ");
172
+ });
173
+
174
+ it("should return correct English translation for part 4", () => {
175
+ const translation = getTranslation("orderWaitingForApproval4", ILanguageEnum.en, {});
176
+ expect(translation).toBe("If your request is approved");
177
+ });
178
+
179
+ it("should return correct English translation for part 5", () => {
180
+ const translation = getTranslation("orderWaitingForApproval5", ILanguageEnum.en, {});
181
+ expect(translation).toBe("The tickets will be sent to your email.");
182
+ });
183
+ });
184
+
185
+ describe("ticketLimitReached", () => {
186
+ it("should return correct English translation for part 1", () => {
187
+ const translation = getTranslation("ticketLimitReached1", ILanguageEnum.en, {});
188
+ expect(translation).toBe("Your order has been received after all tickets in the system were sold out.");
189
+ });
190
+
191
+ it("should return correct Hebrew translation for part 1", () => {
192
+ const translation = getTranslation("ticketLimitReached1", ILanguageEnum.he, {});
193
+ expect(translation).toBe("הזמנתך נקלטה לאחר שהסתיימו הכרטיסים במערכת.");
194
+ });
195
+
196
+ it("should return correct Arabic translation for part 1", () => {
197
+ const translation = getTranslation("ticketLimitReached1", ILanguageEnum.ar, {});
198
+ expect(translation).toBe(
199
+ "تم استلام طلبك بعد نفاد جميع التذاكر في النظام. تمت إضافة اسمك تلقائياً إلى قائمة الانتظار. إذا كانت هناك أي إلغاءات وأصبح ذلك ممكناً، سنقدم التذاكر المتاحة للأعضاء وفقاً لموقعهم في قائمة الانتظار."
200
+ );
201
+ });
202
+
203
+ it("should return valid translations for all supported languages for part 1", () => {
204
+ Object.values(ILanguageEnum).forEach((language) => {
205
+ const translation = getTranslation("ticketLimitReached1", language, {});
206
+ expect(translation).toBeTruthy();
207
+ expect(typeof translation).toBe("string");
208
+ expect(translation.length).toBeGreaterThan(0);
209
+ });
210
+ });
211
+
212
+ it("should return correct English translation for part 2", () => {
213
+ const translation = getTranslation("ticketLimitReached2", ILanguageEnum.en, {});
214
+ expect(translation).toBe("Your name has been automatically added to the waiting list.");
215
+ });
216
+
217
+ it("should return correct English translation for part 3", () => {
218
+ const translation = getTranslation("ticketLimitReached3", ILanguageEnum.en, {});
219
+ expect(translation).toBe("If there are any cancellations and it becomes possible,");
220
+ });
221
+
222
+ it("should return correct English translation for part 4", () => {
223
+ const translation = getTranslation("ticketLimitReached4", ILanguageEnum.en, {});
224
+ expect(translation).toBe("we will offer the available tickets to members,");
225
+ });
226
+
227
+ it("should return correct English translation for part 5", () => {
228
+ const translation = getTranslation("ticketLimitReached5", ILanguageEnum.en, {});
229
+ expect(translation).toBe("according to their position on the waiting list.");
230
+ });
231
+ });
232
+ });