@stevenkellner/team-conduct-api 1.0.36 → 2.0.1

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.
Files changed (218) hide show
  1. package/lib/src/firebase/FirebaseConfiguration.d.ts +45 -1
  2. package/lib/src/firebase/FirebaseConfiguration.js +44 -0
  3. package/lib/src/firebase/Firestore.d.ts +196 -0
  4. package/lib/src/firebase/Firestore.js +235 -0
  5. package/lib/src/{FirestoreScheme.d.ts → firebase/FirestoreScheme.d.ts} +15 -1
  6. package/lib/src/firebase/Messaging.d.ts +64 -0
  7. package/lib/src/firebase/checkAuthentication.d.ts +37 -0
  8. package/lib/src/{checkAuthentication.js → firebase/checkAuthentication.js} +26 -1
  9. package/lib/src/firebase/index.d.ts +4 -0
  10. package/lib/src/firebase/index.js +4 -0
  11. package/lib/src/firebase/pushNotification.d.ts +39 -0
  12. package/lib/src/firebase/pushNotification.js +88 -0
  13. package/lib/src/functions/fine/add.d.ts +10 -13
  14. package/lib/src/functions/fine/add.js +3 -30
  15. package/lib/src/functions/fine/delete.d.ts +10 -13
  16. package/lib/src/functions/fine/delete.js +3 -27
  17. package/lib/src/functions/fine/update.d.ts +10 -13
  18. package/lib/src/functions/fine/update.js +3 -28
  19. package/lib/src/functions/fineTemplate/add.d.ts +6 -9
  20. package/lib/src/functions/fineTemplate/add.js +3 -12
  21. package/lib/src/functions/fineTemplate/delete.d.ts +6 -9
  22. package/lib/src/functions/fineTemplate/delete.js +3 -12
  23. package/lib/src/functions/fineTemplate/update.d.ts +6 -9
  24. package/lib/src/functions/fineTemplate/update.js +3 -12
  25. package/lib/src/functions/invitation/getInvitation.d.ts +40 -43
  26. package/lib/src/functions/invitation/getInvitation.js +57 -88
  27. package/lib/src/functions/invitation/invite.d.ts +1 -2
  28. package/lib/src/functions/invitation/invite.js +3 -18
  29. package/lib/src/functions/invitation/register.d.ts +6 -11
  30. package/lib/src/functions/invitation/register.js +3 -39
  31. package/lib/src/functions/invitation/withdraw.d.ts +1 -2
  32. package/lib/src/functions/invitation/withdraw.js +3 -13
  33. package/lib/src/functions/notification/register.d.ts +7 -10
  34. package/lib/src/functions/notification/register.js +3 -15
  35. package/lib/src/functions/notification/subscribe.d.ts +8 -11
  36. package/lib/src/functions/notification/subscribe.js +3 -14
  37. package/lib/src/functions/paypalMe/edit.d.ts +6 -9
  38. package/lib/src/functions/paypalMe/edit.js +3 -14
  39. package/lib/src/functions/person/add.d.ts +7 -10
  40. package/lib/src/functions/person/add.js +3 -12
  41. package/lib/src/functions/person/delete.d.ts +6 -9
  42. package/lib/src/functions/person/delete.js +3 -14
  43. package/lib/src/functions/person/update.d.ts +7 -10
  44. package/lib/src/functions/person/update.js +3 -13
  45. package/lib/src/functions/team/new.d.ts +9 -12
  46. package/lib/src/functions/team/new.js +3 -22
  47. package/lib/src/functions/user/kickout.d.ts +6 -9
  48. package/lib/src/functions/user/kickout.js +3 -25
  49. package/lib/src/functions/user/login.d.ts +1 -2
  50. package/lib/src/functions/user/login.js +3 -13
  51. package/lib/src/functions/user/roleEdit.d.ts +8 -11
  52. package/lib/src/functions/user/roleEdit.js +3 -18
  53. package/lib/src/index.d.ts +0 -5
  54. package/lib/src/index.js +0 -5
  55. package/lib/src/locales/de.d.ts +10 -67
  56. package/lib/src/locales/de.js +8 -0
  57. package/lib/src/locales/en.d.ts +10 -0
  58. package/lib/src/locales/en.js +19 -2
  59. package/lib/src/types/Configuration.d.ts +33 -15
  60. package/lib/src/types/Configuration.js +24 -12
  61. package/lib/src/types/Currency.d.ts +20 -0
  62. package/lib/src/types/Currency.js +19 -0
  63. package/lib/src/types/Fine.d.ts +41 -0
  64. package/lib/src/types/Fine.js +32 -0
  65. package/lib/src/types/FineAmount.d.ts +160 -9
  66. package/lib/src/types/FineAmount.js +128 -7
  67. package/lib/src/types/FineTemplate.d.ts +41 -0
  68. package/lib/src/types/FineTemplate.js +32 -0
  69. package/lib/src/types/FineTemplateRepetition.d.ts +72 -10
  70. package/lib/src/types/FineTemplateRepetition.js +66 -12
  71. package/lib/src/types/Invitation.d.ts +48 -0
  72. package/lib/src/types/Invitation.js +39 -0
  73. package/lib/src/types/Locale.d.ts +16 -0
  74. package/lib/src/types/Locale.js +16 -0
  75. package/lib/src/types/Localization.d.ts +74 -74
  76. package/lib/src/types/Localization.js +80 -41
  77. package/lib/src/types/MoneyAmount.d.ts +67 -1
  78. package/lib/src/types/MoneyAmount.js +62 -0
  79. package/lib/src/types/NotificationProperties.d.ts +70 -9
  80. package/lib/src/types/NotificationProperties.js +49 -5
  81. package/lib/src/types/PayedState.d.ts +25 -9
  82. package/lib/src/types/PayedState.js +17 -27
  83. package/lib/src/types/Person.d.ts +45 -0
  84. package/lib/src/types/Person.js +36 -0
  85. package/lib/src/types/PersonPrivateProperties.d.ts +28 -0
  86. package/lib/src/types/PersonPrivateProperties.js +25 -0
  87. package/lib/src/types/PersonSignInProperties.d.ts +30 -0
  88. package/lib/src/types/PersonSignInProperties.js +27 -0
  89. package/lib/src/types/Pluralization.d.ts +46 -0
  90. package/lib/src/types/Pluralization.js +46 -0
  91. package/lib/src/types/Team.d.ts +38 -0
  92. package/lib/src/types/Team.js +29 -0
  93. package/lib/src/types/User.d.ts +68 -3
  94. package/lib/src/types/User.js +59 -5
  95. package/lib/src/types/UserRole.d.ts +26 -4
  96. package/lib/src/types/UserRole.js +25 -9
  97. package/lib/src/types/index.d.ts +2 -0
  98. package/lib/src/types/index.js +2 -0
  99. package/lib/test/firebase/FirebaseConfiguration.test.js +155 -0
  100. package/lib/test/firebase/Firestore.test.js +46 -0
  101. package/lib/test/firebase/checkAuthentication.test.d.ts +1 -0
  102. package/lib/test/firebase/checkAuthentication.test.js +305 -0
  103. package/lib/test/firebase/firebase-utils.d.ts +32 -0
  104. package/lib/test/firebase/firebase-utils.js +131 -0
  105. package/lib/test/firebase/pushNotification.test.d.ts +1 -0
  106. package/lib/test/firebase/pushNotification.test.js +300 -0
  107. package/lib/test/locales/localization.de.test.d.ts +1 -0
  108. package/lib/test/locales/localization.de.test.js +144 -0
  109. package/lib/test/locales/localization.en.test.d.ts +1 -0
  110. package/lib/test/locales/localization.en.test.js +144 -0
  111. package/lib/test/types/Configuration.test.d.ts +1 -0
  112. package/lib/test/types/Configuration.test.js +84 -0
  113. package/lib/test/types/Currency.test.d.ts +1 -0
  114. package/lib/test/types/Currency.test.js +41 -0
  115. package/lib/test/types/Fine.test.d.ts +1 -0
  116. package/lib/test/types/Fine.test.js +265 -0
  117. package/lib/test/types/FineAmount.test.d.ts +1 -0
  118. package/lib/test/types/FineAmount.test.js +445 -0
  119. package/lib/test/types/FineTemplate.test.d.ts +1 -0
  120. package/lib/test/types/FineTemplate.test.js +271 -0
  121. package/lib/test/types/FineTemplateRepetition.test.d.ts +1 -0
  122. package/lib/test/types/FineTemplateRepetition.test.js +361 -0
  123. package/lib/test/types/Invitation.test.d.ts +1 -0
  124. package/lib/test/types/Invitation.test.js +269 -0
  125. package/lib/test/types/Locale.test.d.ts +1 -0
  126. package/lib/test/types/Locale.test.js +46 -0
  127. package/lib/test/types/Localization.test.d.ts +1 -0
  128. package/lib/test/types/Localization.test.js +241 -0
  129. package/lib/test/types/MoneyAmount.test.d.ts +1 -0
  130. package/lib/test/types/MoneyAmount.test.js +276 -0
  131. package/lib/test/types/NotificationProperties.test.d.ts +1 -0
  132. package/lib/test/types/NotificationProperties.test.js +258 -0
  133. package/lib/test/types/PayedState.test.d.ts +1 -0
  134. package/lib/test/types/PayedState.test.js +105 -0
  135. package/lib/test/types/Person.test.d.ts +1 -0
  136. package/lib/test/types/Person.test.js +266 -0
  137. package/lib/test/types/PersonPrivateProperties.test.d.ts +1 -0
  138. package/lib/test/types/PersonPrivateProperties.test.js +155 -0
  139. package/lib/test/types/PersonSignInProperties.test.d.ts +1 -0
  140. package/lib/test/types/PersonSignInProperties.test.js +208 -0
  141. package/lib/test/types/Pluralization.test.d.ts +1 -0
  142. package/lib/test/types/Pluralization.test.js +206 -0
  143. package/lib/test/types/Team.test.d.ts +1 -0
  144. package/lib/test/types/Team.test.js +145 -0
  145. package/lib/test/types/User.test.d.ts +1 -0
  146. package/lib/test/types/User.test.js +232 -0
  147. package/lib/test/types/UserRole.test.d.ts +1 -0
  148. package/lib/test/types/UserRole.test.js +140 -0
  149. package/lib/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +10 -9
  151. package/src/firebase/FirebaseConfiguration.ts +49 -1
  152. package/src/firebase/Firestore.ts +248 -0
  153. package/src/{FirestoreScheme.ts → firebase/FirestoreScheme.ts} +15 -1
  154. package/src/firebase/Messaging.ts +64 -0
  155. package/src/{checkAuthentication.ts → firebase/checkAuthentication.ts} +39 -1
  156. package/src/firebase/index.ts +5 -0
  157. package/src/firebase/pushNotification.ts +90 -0
  158. package/src/functions/fine/add.ts +10 -48
  159. package/src/functions/fine/delete.ts +9 -43
  160. package/src/functions/fine/update.ts +10 -44
  161. package/src/functions/fineTemplate/add.ts +7 -23
  162. package/src/functions/fineTemplate/delete.ts +7 -23
  163. package/src/functions/fineTemplate/update.ts +7 -24
  164. package/src/functions/index.ts +0 -1
  165. package/src/functions/invitation/getInvitation.ts +81 -118
  166. package/src/functions/invitation/invite.ts +2 -25
  167. package/src/functions/invitation/register.ts +9 -60
  168. package/src/functions/invitation/withdraw.ts +2 -16
  169. package/src/functions/notification/register.ts +7 -26
  170. package/src/functions/notification/subscribe.ts +8 -26
  171. package/src/functions/paypalMe/edit.ts +7 -25
  172. package/src/functions/person/add.ts +8 -24
  173. package/src/functions/person/delete.ts +6 -25
  174. package/src/functions/person/update.ts +8 -25
  175. package/src/functions/team/new.ts +12 -42
  176. package/src/functions/user/kickout.ts +8 -41
  177. package/src/functions/user/login.ts +2 -16
  178. package/src/functions/user/roleEdit.ts +8 -32
  179. package/src/index.ts +0 -5
  180. package/src/locales/de.ts +10 -1
  181. package/src/locales/en.ts +21 -2
  182. package/src/types/Configuration.ts +33 -23
  183. package/src/types/Currency.ts +24 -0
  184. package/src/types/Fine.ts +41 -0
  185. package/src/types/FineAmount.ts +162 -11
  186. package/src/types/FineTemplate.ts +41 -0
  187. package/src/types/FineTemplateRepetition.ts +75 -17
  188. package/src/types/Invitation.ts +48 -0
  189. package/src/types/Locale.ts +20 -0
  190. package/src/types/Localization.ts +96 -41
  191. package/src/types/MoneyAmount.ts +67 -1
  192. package/src/types/NotificationProperties.ts +67 -9
  193. package/src/types/PayedState.ts +25 -30
  194. package/src/types/Person.ts +45 -0
  195. package/src/types/PersonPrivateProperties.ts +28 -1
  196. package/src/types/PersonSignInProperties.ts +30 -0
  197. package/src/types/Pluralization.ts +46 -0
  198. package/src/types/Team.ts +38 -0
  199. package/src/types/User.ts +70 -4
  200. package/src/types/UserRole.ts +32 -16
  201. package/src/types/index.ts +2 -0
  202. package/lib/src/Firestore.d.ts +0 -24
  203. package/lib/src/Firestore.js +0 -62
  204. package/lib/src/checkAuthentication.d.ts +0 -6
  205. package/lib/src/firebaseFunctionsContext.d.ts +0 -39
  206. package/lib/src/firebaseFunctionsContext.js +0 -43
  207. package/lib/src/pushNotification.d.ts +0 -3
  208. package/lib/src/pushNotification.js +0 -35
  209. package/lib/test/localization-utils.d.ts +0 -1
  210. package/lib/test/localization-utils.js +0 -24
  211. package/lib/test/localization.de.test.js +0 -151
  212. package/lib/test/localization.en.test.js +0 -145
  213. package/src/Firestore.ts +0 -75
  214. package/src/firebaseFunctionsContext.ts +0 -48
  215. package/src/pushNotification.ts +0 -37
  216. /package/lib/src/{FirestoreScheme.js → firebase/FirestoreScheme.js} +0 -0
  217. /package/lib/test/{localization.de.test.d.ts → firebase/FirebaseConfiguration.test.d.ts} +0 -0
  218. /package/lib/test/{localization.en.test.d.ts → firebase/Firestore.test.d.ts} +0 -0
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const FineTemplate_1 = require("../../src/types/FineTemplate");
5
+ const FineAmount_1 = require("../../src/types/FineAmount");
6
+ const FineTemplateRepetition_1 = require("../../src/types/FineTemplateRepetition");
7
+ const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
8
+ describe('FineTemplate', () => {
9
+ describe('FineTemplate.Id', () => {
10
+ describe('FineTemplate.Id type', () => {
11
+ it('should create a valid fine template ID', () => {
12
+ const guid = new typescript_common_functionality_1.Guid('a1234567-89ab-4def-0123-456789abcdef');
13
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build(guid.guidString);
14
+ (0, core_1.expect)(templateId.value).toBeEqual(guid);
15
+ });
16
+ });
17
+ describe('FineTemplate.Id.builder', () => {
18
+ it('should build fine template ID from GUID string', () => {
19
+ const guidString = 'a1234567-89ab-4def-0123-456789abcdef';
20
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build(guidString);
21
+ (0, core_1.expect)(templateId.flatten).toBeEqual(guidString);
22
+ });
23
+ it('should preserve fine template ID value', () => {
24
+ const guidString = 'b2345678-9abc-4ef0-1234-56789abcdef0';
25
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build(guidString);
26
+ (0, core_1.expect)(templateId.flatten).toBeEqual(guidString);
27
+ });
28
+ });
29
+ });
30
+ describe('FineTemplate', () => {
31
+ describe('FineTemplate constructor', () => {
32
+ it('should create fine template with all properties', () => {
33
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
34
+ const reason = 'Late to practice';
35
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.50 });
36
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
37
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition);
38
+ (0, core_1.expect)(template.id).toBeEqual(templateId);
39
+ (0, core_1.expect)(template.reason).toBeEqual(reason);
40
+ (0, core_1.expect)(template.amount).toBeEqual(amount);
41
+ (0, core_1.expect)(template.repetition).toBeEqual(repetition);
42
+ });
43
+ it('should create fine template without repetition', () => {
44
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
45
+ const reason = 'Forgot equipment';
46
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 5.0 });
47
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
48
+ (0, core_1.expect)(template.repetition).toBeEqual(null);
49
+ });
50
+ it('should create fine template with different reasons', () => {
51
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
52
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.0 });
53
+ const template1 = new FineTemplate_1.FineTemplate(templateId, 'Reason 1', amount, null);
54
+ const template2 = new FineTemplate_1.FineTemplate(templateId, 'Reason 2', amount, null);
55
+ (0, core_1.expect)(template1.reason).not.toBeEqual(template2.reason);
56
+ });
57
+ it('should create fine template with money amount', () => {
58
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
59
+ const reason = 'Test reason';
60
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 15.75 });
61
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
62
+ (0, core_1.expect)(template.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
63
+ (0, core_1.expect)(template.amount.amount.value).toBeEqual(15);
64
+ (0, core_1.expect)(template.amount.amount.subunitValue).toBeEqual(75);
65
+ });
66
+ it('should create fine template with item amount', () => {
67
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
68
+ const reason = 'Test reason';
69
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'item', item: 'crateOfBeer', count: 2 });
70
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
71
+ (0, core_1.expect)(template.amount).toBeInstanceOf(FineAmount_1.FineAmount.Item);
72
+ (0, core_1.expect)(template.amount.item).toBeEqual('crateOfBeer');
73
+ (0, core_1.expect)(template.amount.count).toBeEqual(2);
74
+ });
75
+ it('should create fine template with different repetition types', () => {
76
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
77
+ const reason = 'Test reason';
78
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.0 });
79
+ const repetition1 = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 5);
80
+ const repetition2 = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
81
+ const template1 = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition1);
82
+ const template2 = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition2);
83
+ (0, core_1.expect)(template1.repetition?.item).toBeEqual('minute');
84
+ (0, core_1.expect)(template2.repetition?.item).toBeEqual('day');
85
+ });
86
+ });
87
+ describe('FineTemplate.flatten', () => {
88
+ it('should return flattened representation with repetition', () => {
89
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
90
+ const reason = 'Late to practice';
91
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.50 });
92
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
93
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition);
94
+ const flattened = template.flatten;
95
+ (0, core_1.expect)(flattened.id).toBeEqual(templateId.flatten);
96
+ (0, core_1.expect)(flattened.reason).toBeEqual(reason);
97
+ (0, core_1.expect)(flattened.amount).toBeEqual(amount.flatten);
98
+ (0, core_1.expect)(flattened.repetition).not.toBeEqual(null);
99
+ });
100
+ it('should return flattened representation without repetition', () => {
101
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
102
+ const reason = 'One-time fine';
103
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 5.0 });
104
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
105
+ const flattened = template.flatten;
106
+ (0, core_1.expect)(flattened.repetition).toBeEqual(null);
107
+ });
108
+ it('should match the original values', () => {
109
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
110
+ const reason = 'Test reason';
111
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 20.99 });
112
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', 5);
113
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition);
114
+ const flattened = template.flatten;
115
+ (0, core_1.expect)(flattened.id).toBeEqual(template.id.flatten);
116
+ (0, core_1.expect)(flattened.reason).toBeEqual(template.reason);
117
+ (0, core_1.expect)(flattened.amount).toBeEqual(template.amount.flatten);
118
+ });
119
+ it('should have correct structure', () => {
120
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
121
+ const reason = 'Test';
122
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.0 });
123
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
124
+ const flattened = template.flatten;
125
+ (0, core_1.expect)(typeof flattened.id).toBeEqual('string');
126
+ (0, core_1.expect)(typeof flattened.reason).toBeEqual('string');
127
+ (0, core_1.expect)(typeof flattened.amount).toBeEqual('object');
128
+ });
129
+ it('should flatten money amount correctly', () => {
130
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
131
+ const reason = 'Test';
132
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 15.50 });
133
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
134
+ const flattened = template.flatten;
135
+ (0, core_1.expect)(flattened.amount).toBeEqual({ type: 'money', amount: 15.50 });
136
+ });
137
+ it('should flatten item amount correctly', () => {
138
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
139
+ const reason = 'Test';
140
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'item', item: 'crateOfBeer', count: 3 });
141
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
142
+ const flattened = template.flatten;
143
+ (0, core_1.expect)(flattened.amount).toBeEqual({ type: 'item', item: 'crateOfBeer', count: 3 });
144
+ });
145
+ it('should flatten repetition when present', () => {
146
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
147
+ const reason = 'Test';
148
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.0 });
149
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 15);
150
+ const template = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition);
151
+ const flattened = template.flatten;
152
+ (0, core_1.expect)(flattened.repetition?.item).toBeEqual('minute');
153
+ (0, core_1.expect)(flattened.repetition?.maxCount).toBeEqual(15);
154
+ });
155
+ });
156
+ describe('FineTemplate.TypeBuilder', () => {
157
+ it('should build fine template from flattened data with repetition', () => {
158
+ const flattened = {
159
+ id: 'a1111111-1111-4111-1111-111111111111',
160
+ reason: 'Late to practice',
161
+ amount: { type: 'money', amount: 10.50 },
162
+ repetition: { item: 'minute', maxCount: 10 }
163
+ };
164
+ const template = FineTemplate_1.FineTemplate.builder.build(flattened);
165
+ (0, core_1.expect)(template.id.flatten).toBeEqual(flattened.id);
166
+ (0, core_1.expect)(template.reason).toBeEqual(flattened.reason);
167
+ (0, core_1.expect)(template.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
168
+ (0, core_1.expect)(template.amount.amount.value).toBeEqual(10);
169
+ (0, core_1.expect)(template.repetition?.item).toBeEqual('minute');
170
+ });
171
+ it('should build fine template from flattened data without repetition', () => {
172
+ const flattened = {
173
+ id: 'a1111111-1111-4111-1111-111111111111',
174
+ reason: 'One-time fine',
175
+ amount: { type: 'money', amount: 5.00 },
176
+ repetition: null
177
+ };
178
+ const template = FineTemplate_1.FineTemplate.builder.build(flattened);
179
+ (0, core_1.expect)(template.repetition).toBeEqual(null);
180
+ });
181
+ it('should build fine template with money amount', () => {
182
+ const flattened = {
183
+ id: 'a1111111-1111-4111-1111-111111111111',
184
+ reason: 'Test',
185
+ amount: { type: 'money', amount: 20.99 },
186
+ repetition: null
187
+ };
188
+ const template = FineTemplate_1.FineTemplate.builder.build(flattened);
189
+ (0, core_1.expect)(template.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
190
+ (0, core_1.expect)(template.amount.amount.value).toBeEqual(20);
191
+ (0, core_1.expect)(template.amount.amount.subunitValue).toBeEqual(99);
192
+ });
193
+ it('should build fine template with item amount', () => {
194
+ const flattened = {
195
+ id: 'a1111111-1111-4111-1111-111111111111',
196
+ reason: 'Test',
197
+ amount: { type: 'item', item: 'crateOfBeer', count: 2 },
198
+ repetition: null
199
+ };
200
+ const template = FineTemplate_1.FineTemplate.builder.build(flattened);
201
+ (0, core_1.expect)(template.amount).toBeInstanceOf(FineAmount_1.FineAmount.Item);
202
+ (0, core_1.expect)(template.amount.item).toBeEqual('crateOfBeer');
203
+ (0, core_1.expect)(template.amount.count).toBeEqual(2);
204
+ });
205
+ it('should build fine template with different repetition types', () => {
206
+ const flattened1 = {
207
+ id: 'a1111111-1111-4111-1111-111111111111',
208
+ reason: 'Test',
209
+ amount: { type: 'money', amount: 10.00 },
210
+ repetition: { item: 'day', maxCount: null }
211
+ };
212
+ const template = FineTemplate_1.FineTemplate.builder.build(flattened1);
213
+ (0, core_1.expect)(template.repetition?.item).toBeEqual('day');
214
+ (0, core_1.expect)(template.repetition?.maxCount).toBeEqual(null);
215
+ });
216
+ it('should round-trip through flatten and build with repetition', () => {
217
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
218
+ const reason = 'Late to practice';
219
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.50 });
220
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
221
+ const original = new FineTemplate_1.FineTemplate(templateId, reason, amount, repetition);
222
+ const rebuilt = FineTemplate_1.FineTemplate.builder.build(original.flatten);
223
+ (0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
224
+ (0, core_1.expect)(rebuilt.reason).toBeEqual(original.reason);
225
+ (0, core_1.expect)(rebuilt.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
226
+ (0, core_1.expect)(original.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
227
+ (0, core_1.expect)(rebuilt.amount.amount.value).toBeEqual(original.amount.amount.value);
228
+ (0, core_1.expect)(rebuilt.repetition?.item).toBeEqual(original.repetition?.item);
229
+ });
230
+ it('should round-trip through flatten and build without repetition', () => {
231
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
232
+ const reason = 'One-time fine';
233
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 5.0 });
234
+ const original = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
235
+ const rebuilt = FineTemplate_1.FineTemplate.builder.build(original.flatten);
236
+ (0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
237
+ (0, core_1.expect)(rebuilt.repetition).toBeEqual(null);
238
+ });
239
+ it('should round-trip with money amount', () => {
240
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
241
+ const reason = 'Test';
242
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 15.75 });
243
+ const original = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
244
+ const rebuilt = FineTemplate_1.FineTemplate.builder.build(original.flatten);
245
+ (0, core_1.expect)(rebuilt.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
246
+ (0, core_1.expect)(original.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
247
+ (0, core_1.expect)(rebuilt.amount.amount.value).toBeEqual(original.amount.amount.value);
248
+ (0, core_1.expect)(rebuilt.amount.amount.subunitValue).toBeEqual(original.amount.amount.subunitValue);
249
+ });
250
+ it('should round-trip with item amount', () => {
251
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
252
+ const reason = 'Test';
253
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'item', item: 'crateOfBeer', count: 3 });
254
+ const original = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
255
+ const rebuilt = FineTemplate_1.FineTemplate.builder.build(original.flatten);
256
+ (0, core_1.expect)(rebuilt.amount).toBeInstanceOf(FineAmount_1.FineAmount.Item);
257
+ (0, core_1.expect)(original.amount).toBeInstanceOf(FineAmount_1.FineAmount.Item);
258
+ (0, core_1.expect)(rebuilt.amount.item).toBeEqual(original.amount.item);
259
+ (0, core_1.expect)(rebuilt.amount.count).toBeEqual(original.amount.count);
260
+ });
261
+ it('should preserve reason through round-trip', () => {
262
+ const templateId = FineTemplate_1.FineTemplate.Id.builder.build('a1111111-1111-4111-1111-111111111111');
263
+ const reason = 'Specific reason with special characters: äöü!';
264
+ const amount = FineAmount_1.FineAmount.builder.build({ type: 'money', amount: 10.0 });
265
+ const original = new FineTemplate_1.FineTemplate(templateId, reason, amount, null);
266
+ const rebuilt = FineTemplate_1.FineTemplate.builder.build(original.flatten);
267
+ (0, core_1.expect)(rebuilt.reason).toBeEqual(original.reason);
268
+ });
269
+ });
270
+ });
271
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,361 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const FineTemplateRepetition_1 = require("../../src/types/FineTemplateRepetition");
5
+ describe('FineTemplateRepetition', () => {
6
+ describe('FineTemplateRepetition.Item', () => {
7
+ describe('FineTemplateRepetition.Item type', () => {
8
+ it('should be valid repetition item types', () => {
9
+ const item1 = 'minute';
10
+ const item2 = 'day';
11
+ const item3 = 'item';
12
+ const item4 = 'count';
13
+ (0, core_1.expect)(item1).toBeEqual('minute');
14
+ (0, core_1.expect)(item2).toBeEqual('day');
15
+ (0, core_1.expect)(item3).toBeEqual('item');
16
+ (0, core_1.expect)(item4).toBeEqual('count');
17
+ });
18
+ });
19
+ describe('FineTemplateRepetition.Item.all', () => {
20
+ it('should contain all repetition items', () => {
21
+ (0, core_1.expect)(FineTemplateRepetition_1.FineTemplateRepetition.Item.all.length).toBeEqual(4);
22
+ });
23
+ it('should contain minute', () => {
24
+ (0, core_1.expect)(FineTemplateRepetition_1.FineTemplateRepetition.Item.all.includes('minute')).toBeTrue();
25
+ });
26
+ it('should contain day', () => {
27
+ (0, core_1.expect)(FineTemplateRepetition_1.FineTemplateRepetition.Item.all.includes('day')).toBeTrue();
28
+ });
29
+ it('should contain item', () => {
30
+ (0, core_1.expect)(FineTemplateRepetition_1.FineTemplateRepetition.Item.all.includes('item')).toBeTrue();
31
+ });
32
+ it('should contain count', () => {
33
+ (0, core_1.expect)(FineTemplateRepetition_1.FineTemplateRepetition.Item.all.includes('count')).toBeTrue();
34
+ });
35
+ it('should contain only valid repetition item strings', () => {
36
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
37
+ (0, core_1.expect)(typeof item).toBeEqual('string');
38
+ });
39
+ });
40
+ it('should be readonly', () => {
41
+ (0, core_1.expect)(Array.isArray(FineTemplateRepetition_1.FineTemplateRepetition.Item.all)).toBeTrue();
42
+ });
43
+ });
44
+ describe('FineTemplateRepetition.Item.formatted', () => {
45
+ describe('formatted with en locale', () => {
46
+ it('should format minute item', () => {
47
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('minute', 'en');
48
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
49
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
50
+ });
51
+ it('should format day item', () => {
52
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('day', 'en');
53
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
54
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
55
+ });
56
+ it('should format item item', () => {
57
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('item', 'en');
58
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
59
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
60
+ });
61
+ it('should format count item', () => {
62
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('count', 'en');
63
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
64
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
65
+ });
66
+ it('should return different values for different items', () => {
67
+ const minute = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('minute', 'en');
68
+ const day = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('day', 'en');
69
+ (0, core_1.expect)(minute).not.toBeEqual(day);
70
+ });
71
+ });
72
+ describe('formatted with de locale', () => {
73
+ it('should format minute item', () => {
74
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('minute', 'de');
75
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
76
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
77
+ });
78
+ it('should format day item', () => {
79
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('day', 'de');
80
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
81
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
82
+ });
83
+ it('should format item item', () => {
84
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('item', 'de');
85
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
86
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
87
+ });
88
+ it('should format count item', () => {
89
+ const formatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('count', 'de');
90
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
91
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
92
+ });
93
+ });
94
+ describe('formatted for all items and locales', () => {
95
+ it('should format all items in all locales', () => {
96
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
97
+ const enFormatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted(item, 'en');
98
+ const deFormatted = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted(item, 'de');
99
+ (0, core_1.expect)(enFormatted.length).not.toBeEqual(0);
100
+ (0, core_1.expect)(deFormatted.length).not.toBeEqual(0);
101
+ });
102
+ });
103
+ it('should return different values for different locales', () => {
104
+ const enMinute = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('minute', 'en');
105
+ const deMinute = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('minute', 'de');
106
+ const enDay = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('day', 'en');
107
+ const deDay = FineTemplateRepetition_1.FineTemplateRepetition.Item.formatted('day', 'de');
108
+ const allFormattings = [enMinute, deMinute, enDay, deDay];
109
+ const uniqueFormattings = new Set(allFormattings);
110
+ (0, core_1.expect)(uniqueFormattings.size).not.toBeEqual(1);
111
+ });
112
+ });
113
+ });
114
+ describe('FineTemplateRepetition.Item.builder', () => {
115
+ it('should build valid repetition item from string', () => {
116
+ const item = FineTemplateRepetition_1.FineTemplateRepetition.Item.builder.build('minute');
117
+ (0, core_1.expect)(item).toBeEqual('minute');
118
+ });
119
+ it('should preserve repetition item value', () => {
120
+ const item = FineTemplateRepetition_1.FineTemplateRepetition.Item.builder.build('day');
121
+ (0, core_1.expect)(item).toBeEqual('day');
122
+ });
123
+ it('should build all repetition items', () => {
124
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(itemValue => {
125
+ const built = FineTemplateRepetition_1.FineTemplateRepetition.Item.builder.build(itemValue);
126
+ (0, core_1.expect)(built).toBeEqual(itemValue);
127
+ });
128
+ });
129
+ });
130
+ });
131
+ describe('FineTemplateRepetition', () => {
132
+ describe('FineTemplateRepetition constructor', () => {
133
+ it('should create repetition with item and maxCount', () => {
134
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
135
+ (0, core_1.expect)(repetition.item).toBeEqual('minute');
136
+ (0, core_1.expect)(repetition.maxCount).toBeEqual(10);
137
+ });
138
+ it('should create repetition with null maxCount', () => {
139
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
140
+ (0, core_1.expect)(repetition.item).toBeEqual('day');
141
+ (0, core_1.expect)(repetition.maxCount).toBeEqual(null);
142
+ });
143
+ it('should create repetition with all item types', () => {
144
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
145
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition(item, 5);
146
+ (0, core_1.expect)(repetition.item).toBeEqual(item);
147
+ });
148
+ });
149
+ it('should create repetition with zero maxCount', () => {
150
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('item', 0);
151
+ (0, core_1.expect)(repetition.maxCount).toBeEqual(0);
152
+ });
153
+ it('should create repetition with large maxCount', () => {
154
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('count', 1000);
155
+ (0, core_1.expect)(repetition.maxCount).toBeEqual(1000);
156
+ });
157
+ });
158
+ describe('FineTemplateRepetition.formatted', () => {
159
+ describe('formatted with en locale', () => {
160
+ it('should format minute repetition with count', () => {
161
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
162
+ const formatted = repetition.formatted(5, 'en');
163
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
164
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
165
+ });
166
+ it('should format day repetition with count', () => {
167
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
168
+ const formatted = repetition.formatted(3, 'en');
169
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
170
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
171
+ });
172
+ it('should format item repetition with count', () => {
173
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('item', 5);
174
+ const formatted = repetition.formatted(2, 'en');
175
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
176
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
177
+ });
178
+ it('should format count repetition with count', () => {
179
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('count', null);
180
+ const formatted = repetition.formatted(10, 'en');
181
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
182
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
183
+ });
184
+ it('should format with count value 1', () => {
185
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
186
+ const formatted = repetition.formatted(1, 'en');
187
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
188
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
189
+ });
190
+ });
191
+ describe('formatted with de locale', () => {
192
+ it('should format minute repetition with count', () => {
193
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
194
+ const formatted = repetition.formatted(5, 'de');
195
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
196
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
197
+ });
198
+ it('should format day repetition with count', () => {
199
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
200
+ const formatted = repetition.formatted(3, 'de');
201
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
202
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
203
+ });
204
+ });
205
+ describe('formatted for all items and locales', () => {
206
+ it('should format all item types in all locales', () => {
207
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
208
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition(item, 10);
209
+ const enFormatted = repetition.formatted(5, 'en');
210
+ const deFormatted = repetition.formatted(5, 'de');
211
+ (0, core_1.expect)(enFormatted.length).not.toBeEqual(0);
212
+ (0, core_1.expect)(deFormatted.length).not.toBeEqual(0);
213
+ });
214
+ });
215
+ it('should return different values for different counts', () => {
216
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
217
+ const formatted1 = repetition.formatted(1, 'en');
218
+ const formatted5 = repetition.formatted(5, 'en');
219
+ (0, core_1.expect)(typeof formatted1).toBeEqual('string');
220
+ (0, core_1.expect)(typeof formatted5).toBeEqual('string');
221
+ });
222
+ });
223
+ });
224
+ describe('FineTemplateRepetition.formattedWithoutCount', () => {
225
+ describe('formattedWithoutCount with en locale', () => {
226
+ it('should format minute repetition without count', () => {
227
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
228
+ const formatted = repetition.formattedWithoutCount(5, 'en');
229
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
230
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
231
+ });
232
+ it('should format day repetition without count', () => {
233
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
234
+ const formatted = repetition.formattedWithoutCount(3, 'en');
235
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
236
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
237
+ });
238
+ it('should format item repetition without count', () => {
239
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('item', 5);
240
+ const formatted = repetition.formattedWithoutCount(2, 'en');
241
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
242
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
243
+ });
244
+ it('should format count repetition without count', () => {
245
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('count', null);
246
+ const formatted = repetition.formattedWithoutCount(10, 'en');
247
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
248
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
249
+ });
250
+ });
251
+ describe('formattedWithoutCount with de locale', () => {
252
+ it('should format minute repetition without count', () => {
253
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
254
+ const formatted = repetition.formattedWithoutCount(5, 'de');
255
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
256
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
257
+ });
258
+ it('should format day repetition without count', () => {
259
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
260
+ const formatted = repetition.formattedWithoutCount(3, 'de');
261
+ (0, core_1.expect)(typeof formatted).toBeEqual('string');
262
+ (0, core_1.expect)(formatted.length).not.toBeEqual(0);
263
+ });
264
+ });
265
+ describe('formattedWithoutCount for all items and locales', () => {
266
+ it('should format all item types in all locales', () => {
267
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
268
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition(item, 10);
269
+ const enFormatted = repetition.formattedWithoutCount(5, 'en');
270
+ const deFormatted = repetition.formattedWithoutCount(5, 'de');
271
+ (0, core_1.expect)(enFormatted.length).not.toBeEqual(0);
272
+ (0, core_1.expect)(deFormatted.length).not.toBeEqual(0);
273
+ });
274
+ });
275
+ });
276
+ });
277
+ describe('FineTemplateRepetition.flatten', () => {
278
+ it('should return flattened representation with maxCount', () => {
279
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 10);
280
+ const flattened = repetition.flatten;
281
+ (0, core_1.expect)(flattened.item).toBeEqual('minute');
282
+ (0, core_1.expect)(flattened.maxCount).toBeEqual(10);
283
+ });
284
+ it('should return flattened representation with null maxCount', () => {
285
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('day', null);
286
+ const flattened = repetition.flatten;
287
+ (0, core_1.expect)(flattened.item).toBeEqual('day');
288
+ (0, core_1.expect)(flattened.maxCount).toBeEqual(null);
289
+ });
290
+ it('should match the original values', () => {
291
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('item', 5);
292
+ const flattened = repetition.flatten;
293
+ (0, core_1.expect)(flattened.item).toBeEqual(repetition.item);
294
+ (0, core_1.expect)(flattened.maxCount).toBeEqual(repetition.maxCount);
295
+ });
296
+ it('should have correct structure', () => {
297
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('count', 20);
298
+ const flattened = repetition.flatten;
299
+ (0, core_1.expect)(typeof flattened.item).toBeEqual('string');
300
+ (0, core_1.expect)(typeof flattened.maxCount).toBeEqual('number');
301
+ });
302
+ it('should flatten with zero maxCount', () => {
303
+ const repetition = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 0);
304
+ const flattened = repetition.flatten;
305
+ (0, core_1.expect)(flattened.maxCount).toBeEqual(0);
306
+ });
307
+ });
308
+ describe('FineTemplateRepetition.TypeBuilder', () => {
309
+ it('should build repetition from flattened data with maxCount', () => {
310
+ const flattened = {
311
+ item: 'minute',
312
+ maxCount: 10
313
+ };
314
+ const repetition = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(flattened);
315
+ (0, core_1.expect)(repetition.item).toBeEqual('minute');
316
+ (0, core_1.expect)(repetition.maxCount).toBeEqual(10);
317
+ });
318
+ it('should build repetition from flattened data with null maxCount', () => {
319
+ const flattened = {
320
+ item: 'day',
321
+ maxCount: null
322
+ };
323
+ const repetition = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(flattened);
324
+ (0, core_1.expect)(repetition.item).toBeEqual('day');
325
+ (0, core_1.expect)(repetition.maxCount).toBeEqual(null);
326
+ });
327
+ it('should build repetition with all item types', () => {
328
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
329
+ const flattened = { item, maxCount: 5 };
330
+ const repetition = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(flattened);
331
+ (0, core_1.expect)(repetition.item).toBeEqual(item);
332
+ });
333
+ });
334
+ it('should round-trip through flatten and build with maxCount', () => {
335
+ const original = new FineTemplateRepetition_1.FineTemplateRepetition('item', 15);
336
+ const rebuilt = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(original.flatten);
337
+ (0, core_1.expect)(rebuilt.item).toBeEqual(original.item);
338
+ (0, core_1.expect)(rebuilt.maxCount).toBeEqual(original.maxCount);
339
+ });
340
+ it('should round-trip through flatten and build with null maxCount', () => {
341
+ const original = new FineTemplateRepetition_1.FineTemplateRepetition('count', null);
342
+ const rebuilt = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(original.flatten);
343
+ (0, core_1.expect)(rebuilt.item).toBeEqual(original.item);
344
+ (0, core_1.expect)(rebuilt.maxCount).toBeEqual(original.maxCount);
345
+ });
346
+ it('should round-trip with zero maxCount', () => {
347
+ const original = new FineTemplateRepetition_1.FineTemplateRepetition('minute', 0);
348
+ const rebuilt = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(original.flatten);
349
+ (0, core_1.expect)(rebuilt.maxCount).toBeEqual(0);
350
+ });
351
+ it('should round-trip for all item types', () => {
352
+ FineTemplateRepetition_1.FineTemplateRepetition.Item.all.forEach(item => {
353
+ const original = new FineTemplateRepetition_1.FineTemplateRepetition(item, 10);
354
+ const rebuilt = FineTemplateRepetition_1.FineTemplateRepetition.builder.build(original.flatten);
355
+ (0, core_1.expect)(rebuilt.item).toBeEqual(original.item);
356
+ (0, core_1.expect)(rebuilt.maxCount).toBeEqual(original.maxCount);
357
+ });
358
+ });
359
+ });
360
+ });
361
+ });
@@ -0,0 +1 @@
1
+ export {};