@stevenkellner/team-conduct-api 1.0.35 → 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 +41 -42
  26. package/lib/src/functions/invitation/getInvitation.js +58 -81
  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 +83 -109
  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,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const Configuration_1 = require("../../src/types/Configuration");
5
+ const Currency_1 = require("../../src/types/Currency");
6
+ const Locale_1 = require("../../src/types/Locale");
7
+ describe('Configuration', () => {
8
+ describe('Configuration constructor', () => {
9
+ it('should create a configuration with USD and en', () => {
10
+ const config = new Configuration_1.Configuration('USD', 'en');
11
+ (0, core_1.expect)(config.currency).toBeEqual('USD');
12
+ (0, core_1.expect)(config.locale).toBeEqual('en');
13
+ });
14
+ it('should create a configuration with EUR and de', () => {
15
+ const config = new Configuration_1.Configuration('EUR', 'de');
16
+ (0, core_1.expect)(config.currency).toBeEqual('EUR');
17
+ (0, core_1.expect)(config.locale).toBeEqual('de');
18
+ });
19
+ it('should accept all valid currency and locale combinations', () => {
20
+ for (const currency of Currency_1.Currency.all) {
21
+ for (const locale of Locale_1.Locale.all) {
22
+ const config = new Configuration_1.Configuration(currency, locale);
23
+ (0, core_1.expect)(config.currency).toBeEqual(currency);
24
+ (0, core_1.expect)(config.locale).toBeEqual(locale);
25
+ }
26
+ }
27
+ });
28
+ });
29
+ describe('Configuration.flatten', () => {
30
+ it('should return flattened representation', () => {
31
+ const config = new Configuration_1.Configuration('USD', 'en');
32
+ const flattened = config.flatten;
33
+ (0, core_1.expect)(flattened.currency).toBeEqual('USD');
34
+ (0, core_1.expect)(flattened.locale).toBeEqual('en');
35
+ });
36
+ it('should match the original values', () => {
37
+ const config = new Configuration_1.Configuration('EUR', 'de');
38
+ const flattened = config.flatten;
39
+ (0, core_1.expect)(flattened.currency).toBeEqual(config.currency);
40
+ (0, core_1.expect)(flattened.locale).toBeEqual(config.locale);
41
+ });
42
+ it('should have correct structure', () => {
43
+ const config = new Configuration_1.Configuration('USD', 'en');
44
+ const flattened = config.flatten;
45
+ (0, core_1.expect)(Object.keys(flattened).sort()).toBeEqual(['currency', 'locale']);
46
+ });
47
+ });
48
+ describe('Configuration.TypeBuilder', () => {
49
+ it('should build configuration from flattened data', () => {
50
+ const flattened = {
51
+ currency: 'USD',
52
+ locale: 'en'
53
+ };
54
+ const config = Configuration_1.Configuration.builder.build(flattened);
55
+ (0, core_1.expect)(config.currency).toBeEqual('USD');
56
+ (0, core_1.expect)(config.locale).toBeEqual('en');
57
+ });
58
+ it('should build configuration with EUR and de', () => {
59
+ const flattened = {
60
+ currency: 'EUR',
61
+ locale: 'de'
62
+ };
63
+ const config = Configuration_1.Configuration.builder.build(flattened);
64
+ (0, core_1.expect)(config.currency).toBeEqual('EUR');
65
+ (0, core_1.expect)(config.locale).toBeEqual('de');
66
+ });
67
+ it('should round-trip through flatten and build', () => {
68
+ const original = new Configuration_1.Configuration('USD', 'en');
69
+ const rebuilt = Configuration_1.Configuration.builder.build(original.flatten);
70
+ (0, core_1.expect)(rebuilt.currency).toBeEqual(original.currency);
71
+ (0, core_1.expect)(rebuilt.locale).toBeEqual(original.locale);
72
+ });
73
+ it('should round-trip for all combinations', () => {
74
+ for (const currency of Currency_1.Currency.all) {
75
+ for (const locale of Locale_1.Locale.all) {
76
+ const original = new Configuration_1.Configuration(currency, locale);
77
+ const rebuilt = Configuration_1.Configuration.builder.build(original.flatten);
78
+ (0, core_1.expect)(rebuilt.currency).toBeEqual(original.currency);
79
+ (0, core_1.expect)(rebuilt.locale).toBeEqual(original.locale);
80
+ }
81
+ }
82
+ });
83
+ });
84
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const Currency_1 = require("../../src/types/Currency");
5
+ describe('Currency', () => {
6
+ describe('Currency type', () => {
7
+ it('should be a valid currency type', () => {
8
+ const currency1 = 'EUR';
9
+ const currency2 = 'USD';
10
+ (0, core_1.expect)(currency1).toBeEqual('EUR');
11
+ (0, core_1.expect)(currency2).toBeEqual('USD');
12
+ });
13
+ });
14
+ describe('Currency.all', () => {
15
+ it('should contain only valid currency strings', () => {
16
+ for (const currency of Currency_1.Currency.all) {
17
+ (0, core_1.expect)(typeof currency).toBeEqual('string');
18
+ (0, core_1.expect)(currency.length).toBeGreaterThan(0);
19
+ }
20
+ });
21
+ it('should contain all available currencies', () => {
22
+ (0, core_1.expect)(Currency_1.Currency.all.length).toBeEqual(2);
23
+ (0, core_1.expect)(Currency_1.Currency.all.includes('EUR')).toBeTrue();
24
+ (0, core_1.expect)(Currency_1.Currency.all.includes('USD')).toBeTrue();
25
+ });
26
+ });
27
+ describe('Currency.builder', () => {
28
+ it('should build valid currency from string', () => {
29
+ const currency1 = Currency_1.Currency.builder.build('EUR');
30
+ const currency2 = Currency_1.Currency.builder.build('USD');
31
+ (0, core_1.expect)(currency1).toBeEqual('EUR');
32
+ (0, core_1.expect)(currency2).toBeEqual('USD');
33
+ });
34
+ it('should preserve currency value', () => {
35
+ for (const currency of Currency_1.Currency.all) {
36
+ const built = Currency_1.Currency.builder.build(currency);
37
+ (0, core_1.expect)(built).toBeEqual(currency);
38
+ }
39
+ });
40
+ });
41
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@assertive-ts/core");
4
+ const Fine_1 = require("../../src/types/Fine");
5
+ const FineAmount_1 = require("../../src/types/FineAmount");
6
+ const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
7
+ describe('Fine', () => {
8
+ describe('Fine.Id', () => {
9
+ describe('Fine.Id type', () => {
10
+ it('should create a valid fine ID', () => {
11
+ const guid = new typescript_common_functionality_1.Guid('a1234567-89ab-4def-0123-456789abcdef');
12
+ const fineId = Fine_1.Fine.Id.builder.build(guid.guidString);
13
+ (0, core_1.expect)(fineId.value).toBeEqual(guid);
14
+ });
15
+ });
16
+ describe('Fine.Id.builder', () => {
17
+ it('should build fine ID from GUID string', () => {
18
+ const guidString = 'a1234567-89ab-4def-0123-456789abcdef';
19
+ const fineId = Fine_1.Fine.Id.builder.build(guidString);
20
+ (0, core_1.expect)(fineId.flatten).toBeEqual(guidString);
21
+ });
22
+ it('should preserve fine ID value', () => {
23
+ const guidString = 'b2345678-9abc-4def-0123-456789abcdef';
24
+ const fineId = Fine_1.Fine.Id.builder.build(guidString);
25
+ (0, core_1.expect)(fineId.flatten).toBeEqual(guidString);
26
+ });
27
+ });
28
+ });
29
+ describe('Fine', () => {
30
+ describe('Fine constructor', () => {
31
+ it('should create a fine with all properties', () => {
32
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
33
+ const payedState = 'notPayed';
34
+ const date = typescript_common_functionality_1.UtcDate.now;
35
+ const reason = 'Late to practice';
36
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 20.00 });
37
+ const fine = new Fine_1.Fine(fineId, payedState, date, reason, amount);
38
+ (0, core_1.expect)(fine.id).toBeEqual(fineId);
39
+ (0, core_1.expect)(fine.payedState).toBeEqual(payedState);
40
+ (0, core_1.expect)(fine.date).toBeEqual(date);
41
+ (0, core_1.expect)(fine.reason).toBeEqual(reason);
42
+ (0, core_1.expect)(fine.amount).toBeEqual(amount);
43
+ });
44
+ it('should create a fine with payed state', () => {
45
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
46
+ const payedState = 'payed';
47
+ const date = typescript_common_functionality_1.UtcDate.now;
48
+ const reason = 'Missed meeting';
49
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 10.00 });
50
+ const fine = new Fine_1.Fine(fineId, payedState, date, reason, amount);
51
+ (0, core_1.expect)(fine.payedState).toBeEqual('payed');
52
+ });
53
+ it('should create a fine with notPayed state', () => {
54
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
55
+ const payedState = 'notPayed';
56
+ const date = typescript_common_functionality_1.UtcDate.now;
57
+ const reason = 'Forgot equipment';
58
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 3.50 });
59
+ const fine = new Fine_1.Fine(fineId, payedState, date, reason, amount);
60
+ (0, core_1.expect)(fine.payedState).toBeEqual('notPayed');
61
+ });
62
+ it('should create a fine with different reasons', () => {
63
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
64
+ const date = typescript_common_functionality_1.UtcDate.now;
65
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
66
+ const fine1 = new Fine_1.Fine(fineId, 'notPayed', date, 'Reason 1', amount);
67
+ const fine2 = new Fine_1.Fine(fineId, 'notPayed', date, 'Reason 2', amount);
68
+ (0, core_1.expect)(fine1.reason).not.toBeEqual(fine2.reason);
69
+ });
70
+ it('should create a fine with different amounts', () => {
71
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
72
+ const date = typescript_common_functionality_1.UtcDate.now;
73
+ const reason = 'Test fine';
74
+ const amount1 = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
75
+ const amount2 = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 10.00 });
76
+ const fine1 = new Fine_1.Fine(fineId, 'notPayed', date, reason, amount1);
77
+ const fine2 = new Fine_1.Fine(fineId, 'notPayed', date, reason, amount2);
78
+ (0, core_1.expect)(fine1.amount.amount).not.toBeEqual(fine2.amount.amount);
79
+ });
80
+ it('should handle empty reason string', () => {
81
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
82
+ const date = typescript_common_functionality_1.UtcDate.now;
83
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
84
+ const fine = new Fine_1.Fine(fineId, 'notPayed', date, '', amount);
85
+ (0, core_1.expect)(fine.reason).toBeEqual('');
86
+ });
87
+ it('should handle long reason strings', () => {
88
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
89
+ const date = typescript_common_functionality_1.UtcDate.now;
90
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
91
+ const longReason = 'This is a very long reason for a fine that contains many details about what happened';
92
+ const fine = new Fine_1.Fine(fineId, 'notPayed', date, longReason, amount);
93
+ (0, core_1.expect)(fine.reason).toBeEqual(longReason);
94
+ });
95
+ });
96
+ describe('Fine.flatten', () => {
97
+ it('should return flattened representation with all properties', () => {
98
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
99
+ const payedState = 'notPayed';
100
+ const date = typescript_common_functionality_1.UtcDate.now;
101
+ const reason = 'Test reason';
102
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
103
+ const fine = new Fine_1.Fine(fineId, payedState, date, reason, amount);
104
+ const flattened = fine.flatten;
105
+ (0, core_1.expect)(flattened.id).toBeEqual(fineId.flatten);
106
+ (0, core_1.expect)(flattened.payedState).toBeEqual(payedState);
107
+ (0, core_1.expect)(flattened.date).toBeEqual(date.flatten);
108
+ (0, core_1.expect)(flattened.reason).toBeEqual(reason);
109
+ (0, core_1.expect)(flattened.amount).toBeEqual(amount.flatten);
110
+ });
111
+ it('should flatten payed state correctly', () => {
112
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
113
+ const date = typescript_common_functionality_1.UtcDate.now;
114
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
115
+ const fine = new Fine_1.Fine(fineId, 'payed', date, 'Paid fine', amount);
116
+ const flattened = fine.flatten;
117
+ (0, core_1.expect)(flattened.payedState).toBeEqual('payed');
118
+ });
119
+ it('should flatten notPayed state correctly', () => {
120
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
121
+ const date = typescript_common_functionality_1.UtcDate.now;
122
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
123
+ const fine = new Fine_1.Fine(fineId, 'notPayed', date, 'Unpaid fine', amount);
124
+ const flattened = fine.flatten;
125
+ (0, core_1.expect)(flattened.payedState).toBeEqual('notPayed');
126
+ });
127
+ it('should match the original values', () => {
128
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
129
+ const date = typescript_common_functionality_1.UtcDate.now;
130
+ const reason = 'Match test';
131
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 7.25 });
132
+ const fine = new Fine_1.Fine(fineId, 'notPayed', date, reason, amount);
133
+ const flattened = fine.flatten;
134
+ (0, core_1.expect)(flattened.id).toBeEqual(fine.id.flatten);
135
+ (0, core_1.expect)(flattened.payedState).toBeEqual(fine.payedState);
136
+ (0, core_1.expect)(flattened.reason).toBeEqual(fine.reason);
137
+ });
138
+ it('should have correct structure', () => {
139
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
140
+ const date = typescript_common_functionality_1.UtcDate.now;
141
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
142
+ const fine = new Fine_1.Fine(fineId, 'notPayed', date, 'Structure test', amount);
143
+ const flattened = fine.flatten;
144
+ (0, core_1.expect)(typeof flattened.id).toBeEqual('string');
145
+ (0, core_1.expect)(typeof flattened.payedState).toBeEqual('string');
146
+ (0, core_1.expect)(typeof flattened.date).toBeEqual('string');
147
+ (0, core_1.expect)(typeof flattened.reason).toBeEqual('string');
148
+ (0, core_1.expect)(typeof flattened.amount).toBeEqual('object');
149
+ });
150
+ });
151
+ describe('Fine.TypeBuilder', () => {
152
+ it('should build fine from flattened data', () => {
153
+ const flattened = {
154
+ id: 'a1111111-1111-4111-1111-111111111111',
155
+ payedState: 'notPayed',
156
+ date: typescript_common_functionality_1.UtcDate.now.flatten,
157
+ reason: 'Build test',
158
+ amount: {
159
+ type: 'money',
160
+ amount: 5.50
161
+ }
162
+ };
163
+ const fine = Fine_1.Fine.builder.build(flattened);
164
+ (0, core_1.expect)(fine.id.flatten).toBeEqual(flattened.id);
165
+ (0, core_1.expect)(fine.payedState).toBeEqual(flattened.payedState);
166
+ (0, core_1.expect)(fine.reason).toBeEqual(flattened.reason);
167
+ (0, core_1.expect)(fine.amount).toBeInstanceOf(FineAmount_1.FineAmount.Money);
168
+ (0, core_1.expect)(fine.amount.amount.value).toBeEqual(5);
169
+ (0, core_1.expect)(fine.amount.amount.subunitValue).toBeEqual(50);
170
+ });
171
+ it('should build fine with payed state', () => {
172
+ const flattened = {
173
+ id: 'a1111111-1111-4111-1111-111111111111',
174
+ payedState: 'payed',
175
+ date: typescript_common_functionality_1.UtcDate.now.flatten,
176
+ reason: 'Payed fine',
177
+ amount: {
178
+ type: 'money',
179
+ amount: 3.00
180
+ }
181
+ };
182
+ const fine = Fine_1.Fine.builder.build(flattened);
183
+ (0, core_1.expect)(fine.payedState).toBeEqual('payed');
184
+ });
185
+ it('should build fine with notPayed state', () => {
186
+ const flattened = {
187
+ id: 'a1111111-1111-4111-1111-111111111111',
188
+ payedState: 'notPayed',
189
+ date: typescript_common_functionality_1.UtcDate.now.flatten,
190
+ reason: 'Unpaid fine',
191
+ amount: {
192
+ type: 'money',
193
+ amount: 7.00
194
+ }
195
+ };
196
+ const fine = Fine_1.Fine.builder.build(flattened);
197
+ (0, core_1.expect)(fine.payedState).toBeEqual('notPayed');
198
+ });
199
+ it('should build fine with different reasons', () => {
200
+ const flattened1 = {
201
+ id: 'a1111111-1111-4111-1111-111111111111',
202
+ payedState: 'notPayed',
203
+ date: typescript_common_functionality_1.UtcDate.now.flatten,
204
+ reason: 'Reason A',
205
+ amount: {
206
+ type: 'money',
207
+ amount: 5.00
208
+ }
209
+ };
210
+ const flattened2 = {
211
+ id: 'a1111111-1111-4111-1111-111111111111',
212
+ payedState: 'notPayed',
213
+ date: typescript_common_functionality_1.UtcDate.now.flatten,
214
+ reason: 'Reason B',
215
+ amount: {
216
+ type: 'money',
217
+ amount: 5.00
218
+ }
219
+ };
220
+ const fine1 = Fine_1.Fine.builder.build(flattened1);
221
+ const fine2 = Fine_1.Fine.builder.build(flattened2);
222
+ (0, core_1.expect)(fine1.reason).not.toBeEqual(fine2.reason);
223
+ });
224
+ it('should round-trip through flatten and build', () => {
225
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
226
+ const date = typescript_common_functionality_1.UtcDate.now;
227
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 12.00 });
228
+ const original = new Fine_1.Fine(fineId, 'notPayed', date, 'Round-trip test', amount);
229
+ const rebuilt = Fine_1.Fine.builder.build(original.flatten);
230
+ (0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
231
+ (0, core_1.expect)(rebuilt.payedState).toBeEqual(original.payedState);
232
+ (0, core_1.expect)(rebuilt.reason).toBeEqual(original.reason);
233
+ (0, core_1.expect)(rebuilt.amount.amount).toBeEqual(original.amount.amount);
234
+ });
235
+ it('should round-trip with payed state', () => {
236
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
237
+ const date = typescript_common_functionality_1.UtcDate.now;
238
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 12.00 });
239
+ const original = new Fine_1.Fine(fineId, 'payed', date, 'Payed round-trip', amount);
240
+ const rebuilt = Fine_1.Fine.builder.build(original.flatten);
241
+ (0, core_1.expect)(rebuilt.payedState).toBeEqual('payed');
242
+ });
243
+ it('should round-trip with empty reason', () => {
244
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
245
+ const date = typescript_common_functionality_1.UtcDate.now;
246
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 5.00 });
247
+ const original = new Fine_1.Fine(fineId, 'notPayed', date, '', amount);
248
+ const rebuilt = Fine_1.Fine.builder.build(original.flatten);
249
+ (0, core_1.expect)(rebuilt.reason).toBeEqual('');
250
+ });
251
+ it('should preserve all properties through multiple round-trips', () => {
252
+ const fineId = Fine_1.Fine.Id.builder.build('a1111111-1111-4111-1111-111111111111');
253
+ const date = typescript_common_functionality_1.UtcDate.now;
254
+ const amount = FineAmount_1.FineAmount.Money.builder.build({ type: 'money', amount: 6.33 });
255
+ const original = new Fine_1.Fine(fineId, 'notPayed', date, 'Multiple round-trips', amount);
256
+ const rebuilt1 = Fine_1.Fine.builder.build(original.flatten);
257
+ const rebuilt2 = Fine_1.Fine.builder.build(rebuilt1.flatten);
258
+ (0, core_1.expect)(rebuilt2.id.flatten).toBeEqual(original.id.flatten);
259
+ (0, core_1.expect)(rebuilt2.payedState).toBeEqual(original.payedState);
260
+ (0, core_1.expect)(rebuilt2.reason).toBeEqual(original.reason);
261
+ (0, core_1.expect)(rebuilt2.amount.amount).toBeEqual(original.amount.amount);
262
+ });
263
+ });
264
+ });
265
+ });
@@ -0,0 +1 @@
1
+ export {};