@stevenkellner/team-conduct-api 2.0.18 → 2.0.19

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 (231) hide show
  1. package/lib/src/functions/fine/add.d.ts +3 -8
  2. package/lib/src/functions/fine/add.js +1 -2
  3. package/lib/src/functions/fine/delete.d.ts +1 -6
  4. package/lib/src/functions/fine/delete.js +2 -3
  5. package/lib/src/functions/fine/update.d.ts +2 -8
  6. package/lib/src/functions/fine/update.js +1 -3
  7. package/lib/src/functions/fineTemplate/add.d.ts +3 -3
  8. package/lib/src/functions/fineTemplate/update.d.ts +3 -3
  9. package/lib/src/functions/firebaseFunctionsContext.d.ts +34 -1
  10. package/lib/src/functions/firebaseFunctionsContext.js +33 -33
  11. package/lib/src/functions/index.d.ts +10 -8
  12. package/lib/src/functions/index.js +11 -8
  13. package/lib/src/functions/notification/markNotificationAsRead.d.ts +14 -0
  14. package/lib/src/functions/notification/{subscribe.js → markNotificationAsRead.js} +5 -7
  15. package/lib/src/functions/person/kickout.d.ts +6 -6
  16. package/lib/src/functions/person/kickout.js +4 -4
  17. package/lib/src/functions/person/roleEdit.d.ts +5 -5
  18. package/lib/src/functions/person/roleEdit.js +3 -3
  19. package/lib/src/functions/{paypalMe/edit.d.ts → team/delete.d.ts} +5 -7
  20. package/lib/src/functions/{paypalMe/edit.js → team/delete.js} +4 -5
  21. package/lib/src/functions/team/new.d.ts +18 -18
  22. package/lib/src/functions/team/new.js +8 -4
  23. package/lib/src/functions/team/update.d.ts +34 -0
  24. package/lib/src/functions/team/update.js +23 -0
  25. package/lib/src/functions/user/register.d.ts +4 -0
  26. package/lib/src/functions/user/register.js +3 -1
  27. package/lib/src/functions/user/update.d.ts +26 -0
  28. package/lib/src/functions/user/update.js +15 -0
  29. package/lib/src/index.d.ts +1 -1
  30. package/lib/src/index.js +1 -1
  31. package/lib/src/locales/de.d.ts +1 -1
  32. package/lib/src/locales/de.js +6 -2
  33. package/lib/src/locales/en.d.ts +6 -2
  34. package/lib/src/locales/en.js +6 -2
  35. package/lib/src/types/{MoneyAmount.d.ts → Money.d.ts} +23 -23
  36. package/lib/src/types/{MoneyAmount.js → Money.js} +25 -25
  37. package/lib/src/types/fine/Fine.d.ts +275 -0
  38. package/lib/src/types/fine/Fine.js +318 -0
  39. package/lib/src/types/fine/FineTemplate.d.ts +154 -0
  40. package/lib/src/types/fine/FineTemplate.js +170 -0
  41. package/lib/src/types/{PayedState.d.ts → fine/PayedState.d.ts} +1 -1
  42. package/lib/src/types/{PayedState.js → fine/PayedState.js} +1 -1
  43. package/lib/src/types/fine/index.d.ts +3 -0
  44. package/lib/src/{firebase → types/fine}/index.js +3 -6
  45. package/lib/src/types/index.d.ts +7 -18
  46. package/lib/src/types/index.js +7 -18
  47. package/lib/src/types/{Localization.d.ts → localization/Localization.d.ts} +15 -43
  48. package/lib/src/types/localization/Localization.js +54 -0
  49. package/lib/src/types/localization/PluralLocalization.d.ts +23 -0
  50. package/lib/src/types/localization/PluralLocalization.js +35 -0
  51. package/lib/src/types/{Pluralization.d.ts → localization/Pluralization.d.ts} +1 -0
  52. package/lib/src/types/{Pluralization.js → localization/Pluralization.js} +1 -0
  53. package/lib/src/types/localization/ValueLocalization.d.ts +22 -0
  54. package/lib/src/types/localization/ValueLocalization.js +41 -0
  55. package/lib/src/types/localization/index.d.ts +5 -0
  56. package/lib/src/types/localization/index.js +21 -0
  57. package/lib/src/types/notification/InAppNotification.d.ts +152 -0
  58. package/lib/src/types/notification/InAppNotification.js +136 -0
  59. package/lib/src/types/notification/index.d.ts +1 -0
  60. package/lib/src/types/notification/index.js +17 -0
  61. package/lib/src/types/{Person.d.ts → person/Person.d.ts} +3 -3
  62. package/lib/src/types/{Person.js → person/Person.js} +3 -3
  63. package/lib/src/types/{PersonProperties.d.ts → person/PersonProperties.d.ts} +8 -7
  64. package/lib/src/types/{PersonProperties.js → person/PersonProperties.js} +7 -6
  65. package/lib/src/types/{PersonSignInProperties.d.ts → person/PersonSignInProperties.d.ts} +9 -11
  66. package/lib/src/types/{PersonSignInProperties.js → person/PersonSignInProperties.js} +7 -10
  67. package/lib/src/types/person/index.d.ts +3 -0
  68. package/lib/src/types/person/index.js +19 -0
  69. package/lib/src/types/{Invitation.d.ts → team/Invitation.d.ts} +1 -1
  70. package/lib/src/types/{Invitation.js → team/Invitation.js} +1 -1
  71. package/lib/src/types/team/Team.d.ts +144 -0
  72. package/lib/src/types/team/Team.js +141 -0
  73. package/lib/src/types/team/TeamRole.d.ts +30 -0
  74. package/lib/src/types/{UserRole.js → team/TeamRole.js} +16 -15
  75. package/lib/src/types/team/index.d.ts +3 -0
  76. package/lib/src/types/team/index.js +19 -0
  77. package/lib/src/types/{NotificationProperties.d.ts → user/NotificationProperties.d.ts} +8 -3
  78. package/lib/src/types/{NotificationProperties.js → user/NotificationProperties.js} +4 -0
  79. package/lib/src/types/user/User.d.ts +328 -0
  80. package/lib/src/types/user/User.js +355 -0
  81. package/lib/src/types/user/index.d.ts +2 -0
  82. package/lib/src/types/user/index.js +18 -0
  83. package/lib/src/utils/StaticUnionTypeBuilder.d.ts +9 -0
  84. package/lib/src/utils/StaticUnionTypeBuilder.js +23 -0
  85. package/lib/src/utils/index.d.ts +1 -0
  86. package/lib/src/utils/index.js +17 -0
  87. package/lib/tsconfig.tsbuildinfo +1 -1
  88. package/package.json +4 -3
  89. package/src/functions/fine/add.ts +3 -5
  90. package/src/functions/fine/delete.ts +3 -5
  91. package/src/functions/fine/update.ts +2 -5
  92. package/src/functions/firebaseFunctionsContext.ts +40 -40
  93. package/src/functions/index.ts +11 -9
  94. package/src/functions/notification/markNotificationAsRead.ts +19 -0
  95. package/src/functions/person/add.ts +1 -1
  96. package/src/functions/person/kickout.ts +6 -6
  97. package/src/functions/person/roleEdit.ts +5 -5
  98. package/src/functions/{paypalMe/edit.ts → team/delete.ts} +5 -7
  99. package/src/functions/team/new.ts +19 -11
  100. package/src/functions/team/update.ts +40 -0
  101. package/src/functions/user/register.ts +7 -3
  102. package/src/functions/user/update.ts +29 -0
  103. package/src/index.ts +1 -1
  104. package/src/locales/de.ts +7 -3
  105. package/src/locales/en.ts +7 -3
  106. package/src/types/{MoneyAmount.ts → Money.ts} +29 -29
  107. package/src/types/fine/Fine.ts +399 -0
  108. package/src/types/fine/FineTemplate.ts +219 -0
  109. package/src/types/{PayedState.ts → fine/PayedState.ts} +2 -2
  110. package/src/types/fine/index.ts +3 -0
  111. package/src/types/index.ts +7 -18
  112. package/src/types/{Localization.ts → localization/Localization.ts} +7 -64
  113. package/src/types/localization/PluralLocalization.ts +32 -0
  114. package/src/types/{Pluralization.ts → localization/Pluralization.ts} +1 -0
  115. package/src/types/localization/ValueLocalization.ts +36 -0
  116. package/src/types/localization/index.ts +5 -0
  117. package/src/types/notification/InAppNotification.ts +184 -0
  118. package/src/types/notification/index.ts +1 -0
  119. package/src/types/{Person.ts → person/Person.ts} +3 -3
  120. package/src/types/{PersonProperties.ts → person/PersonProperties.ts} +8 -7
  121. package/src/types/{PersonSignInProperties.ts → person/PersonSignInProperties.ts} +13 -12
  122. package/src/types/person/index.ts +3 -0
  123. package/src/types/{Invitation.ts → team/Invitation.ts} +1 -1
  124. package/src/types/team/Team.ts +204 -0
  125. package/src/types/{UserRole.ts → team/TeamRole.ts} +19 -17
  126. package/src/types/team/index.ts +3 -0
  127. package/src/types/{NotificationProperties.ts → user/NotificationProperties.ts} +12 -3
  128. package/src/types/user/User.ts +451 -0
  129. package/src/types/user/index.ts +2 -0
  130. package/src/utils/StaticUnionTypeBuilder.ts +23 -0
  131. package/src/utils/index.ts +1 -0
  132. package/lib/src/firebase/FirebaseConfiguration.d.ts +0 -64
  133. package/lib/src/firebase/FirebaseConfiguration.js +0 -79
  134. package/lib/src/firebase/Firestore.d.ts +0 -201
  135. package/lib/src/firebase/Firestore.js +0 -244
  136. package/lib/src/firebase/FirestoreScheme.d.ts +0 -42
  137. package/lib/src/firebase/FirestoreScheme.js +0 -2
  138. package/lib/src/firebase/Messaging.d.ts +0 -90
  139. package/lib/src/firebase/Messaging.js +0 -2
  140. package/lib/src/firebase/checkAuthentication.d.ts +0 -38
  141. package/lib/src/firebase/checkAuthentication.js +0 -64
  142. package/lib/src/firebase/index.d.ts +0 -6
  143. package/lib/src/firebase/pushNotification.d.ts +0 -39
  144. package/lib/src/firebase/pushNotification.js +0 -88
  145. package/lib/src/functions/notification/subscribe.d.ts +0 -18
  146. package/lib/src/types/Configuration.d.ts +0 -46
  147. package/lib/src/types/Configuration.js +0 -51
  148. package/lib/src/types/Fine.d.ts +0 -71
  149. package/lib/src/types/Fine.js +0 -74
  150. package/lib/src/types/FineAmount.d.ts +0 -207
  151. package/lib/src/types/FineAmount.js +0 -238
  152. package/lib/src/types/FineTemplate.d.ts +0 -69
  153. package/lib/src/types/FineTemplate.js +0 -72
  154. package/lib/src/types/FineTemplateRepetition.d.ts +0 -87
  155. package/lib/src/types/FineTemplateRepetition.js +0 -103
  156. package/lib/src/types/Localization.js +0 -115
  157. package/lib/src/types/Team.d.ts +0 -62
  158. package/lib/src/types/Team.js +0 -64
  159. package/lib/src/types/User.d.ts +0 -221
  160. package/lib/src/types/User.js +0 -235
  161. package/lib/src/types/UserRole.d.ts +0 -29
  162. package/lib/test/firebase/FirebaseConfiguration.test.d.ts +0 -1
  163. package/lib/test/firebase/FirebaseConfiguration.test.js +0 -158
  164. package/lib/test/firebase/Firestore.test.d.ts +0 -1
  165. package/lib/test/firebase/Firestore.test.js +0 -46
  166. package/lib/test/firebase/checkAuthentication.test.d.ts +0 -1
  167. package/lib/test/firebase/checkAuthentication.test.js +0 -356
  168. package/lib/test/firebase/firebase-utils.d.ts +0 -32
  169. package/lib/test/firebase/firebase-utils.js +0 -134
  170. package/lib/test/firebase/pushNotification.test.d.ts +0 -1
  171. package/lib/test/firebase/pushNotification.test.js +0 -300
  172. package/lib/test/locales/localization.de.test.d.ts +0 -1
  173. package/lib/test/locales/localization.de.test.js +0 -144
  174. package/lib/test/locales/localization.en.test.d.ts +0 -1
  175. package/lib/test/locales/localization.en.test.js +0 -144
  176. package/lib/test/types/Configuration.test.d.ts +0 -1
  177. package/lib/test/types/Configuration.test.js +0 -84
  178. package/lib/test/types/Currency.test.d.ts +0 -1
  179. package/lib/test/types/Currency.test.js +0 -41
  180. package/lib/test/types/Fine.test.d.ts +0 -1
  181. package/lib/test/types/Fine.test.js +0 -265
  182. package/lib/test/types/FineAmount.test.d.ts +0 -1
  183. package/lib/test/types/FineAmount.test.js +0 -445
  184. package/lib/test/types/FineTemplate.test.d.ts +0 -1
  185. package/lib/test/types/FineTemplate.test.js +0 -271
  186. package/lib/test/types/FineTemplateRepetition.test.d.ts +0 -1
  187. package/lib/test/types/FineTemplateRepetition.test.js +0 -361
  188. package/lib/test/types/Invitation.test.d.ts +0 -1
  189. package/lib/test/types/Invitation.test.js +0 -269
  190. package/lib/test/types/Locale.test.d.ts +0 -1
  191. package/lib/test/types/Locale.test.js +0 -46
  192. package/lib/test/types/Localization.test.d.ts +0 -1
  193. package/lib/test/types/Localization.test.js +0 -241
  194. package/lib/test/types/MoneyAmount.test.d.ts +0 -1
  195. package/lib/test/types/MoneyAmount.test.js +0 -276
  196. package/lib/test/types/NotificationProperties.test.d.ts +0 -1
  197. package/lib/test/types/NotificationProperties.test.js +0 -258
  198. package/lib/test/types/PayedState.test.d.ts +0 -1
  199. package/lib/test/types/PayedState.test.js +0 -136
  200. package/lib/test/types/Person.test.d.ts +0 -1
  201. package/lib/test/types/Person.test.js +0 -266
  202. package/lib/test/types/PersonProperties.test.d.ts +0 -1
  203. package/lib/test/types/PersonProperties.test.js +0 -155
  204. package/lib/test/types/PersonSignInProperties.test.d.ts +0 -1
  205. package/lib/test/types/PersonSignInProperties.test.js +0 -208
  206. package/lib/test/types/Pluralization.test.d.ts +0 -1
  207. package/lib/test/types/Pluralization.test.js +0 -206
  208. package/lib/test/types/Team.test.d.ts +0 -1
  209. package/lib/test/types/Team.test.js +0 -145
  210. package/lib/test/types/User.test.d.ts +0 -1
  211. package/lib/test/types/User.test.js +0 -450
  212. package/lib/test/types/UserRole.test.d.ts +0 -1
  213. package/lib/test/types/UserRole.test.js +0 -140
  214. package/src/firebase/FirebaseConfiguration.ts +0 -99
  215. package/src/firebase/Firestore.ts +0 -258
  216. package/src/firebase/FirestoreScheme.ts +0 -41
  217. package/src/firebase/Messaging.ts +0 -93
  218. package/src/firebase/checkAuthentication.ts +0 -91
  219. package/src/firebase/index.ts +0 -7
  220. package/src/firebase/pushNotification.ts +0 -90
  221. package/src/functions/notification/subscribe.ts +0 -23
  222. package/src/types/Configuration.ts +0 -65
  223. package/src/types/Fine.ts +0 -100
  224. package/src/types/FineAmount.ts +0 -303
  225. package/src/types/FineTemplate.ts +0 -96
  226. package/src/types/FineTemplateRepetition.ts +0 -125
  227. package/src/types/Team.ts +0 -87
  228. package/src/types/User.ts +0 -302
  229. /package/lib/src/types/{Locale.d.ts → localization/Locale.d.ts} +0 -0
  230. /package/lib/src/types/{Locale.js → localization/Locale.js} +0 -0
  231. /package/src/types/{Locale.ts → localization/Locale.ts} +0 -0
@@ -1,276 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@assertive-ts/core");
4
- const MoneyAmount_1 = require("../../src/types/MoneyAmount");
5
- const Configuration_1 = require("../../src/types/Configuration");
6
- describe('MoneyAmount', () => {
7
- describe('MoneyAmount constructor', () => {
8
- it('should create a money amount with value and subunit', () => {
9
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
10
- (0, core_1.expect)(amount.value).toBeEqual(10);
11
- (0, core_1.expect)(amount.subunitValue).toBeEqual(50);
12
- });
13
- it('should create a money amount with zero value', () => {
14
- const amount = new MoneyAmount_1.MoneyAmount(0, 0);
15
- (0, core_1.expect)(amount.value).toBeEqual(0);
16
- (0, core_1.expect)(amount.subunitValue).toBeEqual(0);
17
- });
18
- it('should create a money amount with only subunit value', () => {
19
- const amount = new MoneyAmount_1.MoneyAmount(0, 75);
20
- (0, core_1.expect)(amount.value).toBeEqual(0);
21
- (0, core_1.expect)(amount.subunitValue).toBeEqual(75);
22
- });
23
- it('should create a money amount with large values', () => {
24
- const amount = new MoneyAmount_1.MoneyAmount(1000, 99);
25
- (0, core_1.expect)(amount.value).toBeEqual(1000);
26
- (0, core_1.expect)(amount.subunitValue).toBeEqual(99);
27
- });
28
- });
29
- describe('MoneyAmount.zero', () => {
30
- it('should return a money amount with zero value', () => {
31
- const zero = MoneyAmount_1.MoneyAmount.zero;
32
- (0, core_1.expect)(zero.value).toBeEqual(0);
33
- (0, core_1.expect)(zero.subunitValue).toBeEqual(0);
34
- });
35
- it('should return a new instance each time', () => {
36
- const zero1 = MoneyAmount_1.MoneyAmount.zero;
37
- const zero2 = MoneyAmount_1.MoneyAmount.zero;
38
- (0, core_1.expect)(zero1.value).toBeEqual(zero2.value);
39
- (0, core_1.expect)(zero1.subunitValue).toBeEqual(zero2.subunitValue);
40
- });
41
- it('should have complete value of zero', () => {
42
- const zero = MoneyAmount_1.MoneyAmount.zero;
43
- (0, core_1.expect)(zero.completeValue).toBeEqual(0);
44
- });
45
- });
46
- describe('MoneyAmount.added', () => {
47
- it('should add two money amounts without carry', () => {
48
- const amount1 = new MoneyAmount_1.MoneyAmount(10, 25);
49
- const amount2 = new MoneyAmount_1.MoneyAmount(5, 30);
50
- const result = amount1.added(amount2);
51
- (0, core_1.expect)(result.value).toBeEqual(15);
52
- (0, core_1.expect)(result.subunitValue).toBeEqual(55);
53
- });
54
- it('should add two money amounts with carry', () => {
55
- const amount1 = new MoneyAmount_1.MoneyAmount(10, 60);
56
- const amount2 = new MoneyAmount_1.MoneyAmount(5, 50);
57
- const result = amount1.added(amount2);
58
- (0, core_1.expect)(result.value).toBeEqual(16);
59
- (0, core_1.expect)(result.subunitValue).toBeEqual(10);
60
- });
61
- it('should add zero to amount', () => {
62
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
63
- const result = amount.added(MoneyAmount_1.MoneyAmount.zero);
64
- (0, core_1.expect)(result.value).toBeEqual(10);
65
- (0, core_1.expect)(result.subunitValue).toBeEqual(50);
66
- });
67
- it('should handle multiple carries', () => {
68
- const amount1 = new MoneyAmount_1.MoneyAmount(10, 99);
69
- const amount2 = new MoneyAmount_1.MoneyAmount(5, 99);
70
- const result = amount1.added(amount2);
71
- (0, core_1.expect)(result.value).toBeEqual(16);
72
- (0, core_1.expect)(result.subunitValue).toBeEqual(98);
73
- });
74
- it('should add amounts with only subunit values', () => {
75
- const amount1 = new MoneyAmount_1.MoneyAmount(0, 40);
76
- const amount2 = new MoneyAmount_1.MoneyAmount(0, 30);
77
- const result = amount1.added(amount2);
78
- (0, core_1.expect)(result.value).toBeEqual(0);
79
- (0, core_1.expect)(result.subunitValue).toBeEqual(70);
80
- });
81
- it('should carry over from subunit addition', () => {
82
- const amount1 = new MoneyAmount_1.MoneyAmount(0, 80);
83
- const amount2 = new MoneyAmount_1.MoneyAmount(0, 50);
84
- const result = amount1.added(amount2);
85
- (0, core_1.expect)(result.value).toBeEqual(1);
86
- (0, core_1.expect)(result.subunitValue).toBeEqual(30);
87
- });
88
- it('should not modify original amounts', () => {
89
- const amount1 = new MoneyAmount_1.MoneyAmount(10, 50);
90
- const amount2 = new MoneyAmount_1.MoneyAmount(5, 30);
91
- amount1.added(amount2);
92
- (0, core_1.expect)(amount1.value).toBeEqual(10);
93
- (0, core_1.expect)(amount1.subunitValue).toBeEqual(50);
94
- });
95
- });
96
- describe('MoneyAmount.multiplied', () => {
97
- it('should multiply money amount by integer', () => {
98
- const amount = new MoneyAmount_1.MoneyAmount(10, 25);
99
- const result = amount.multiplied(2);
100
- (0, core_1.expect)(result.value).toBeEqual(20);
101
- (0, core_1.expect)(result.subunitValue).toBeEqual(50);
102
- });
103
- it('should multiply with carry from subunit', () => {
104
- const amount = new MoneyAmount_1.MoneyAmount(10, 60);
105
- const result = amount.multiplied(2);
106
- (0, core_1.expect)(result.value).toBeEqual(21);
107
- (0, core_1.expect)(result.subunitValue).toBeEqual(20);
108
- });
109
- it('should multiply by zero', () => {
110
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
111
- const result = amount.multiplied(0);
112
- (0, core_1.expect)(result.value).toBeEqual(0);
113
- (0, core_1.expect)(result.subunitValue).toBeEqual(0);
114
- });
115
- it('should multiply by one', () => {
116
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
117
- const result = amount.multiplied(1);
118
- (0, core_1.expect)(result.value).toBeEqual(10);
119
- (0, core_1.expect)(result.subunitValue).toBeEqual(50);
120
- });
121
- it('should multiply by decimal factor', () => {
122
- const amount = new MoneyAmount_1.MoneyAmount(10, 0);
123
- const result = amount.multiplied(1.5);
124
- (0, core_1.expect)(result.value).toBeEqual(15);
125
- (0, core_1.expect)(result.subunitValue).toBeEqual(0);
126
- });
127
- it('should handle large multipliers', () => {
128
- const amount = new MoneyAmount_1.MoneyAmount(5, 25);
129
- const result = amount.multiplied(10);
130
- (0, core_1.expect)(result.value).toBeEqual(52);
131
- (0, core_1.expect)(result.subunitValue).toBeEqual(50);
132
- });
133
- it('should not modify original amount', () => {
134
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
135
- amount.multiplied(3);
136
- (0, core_1.expect)(amount.value).toBeEqual(10);
137
- (0, core_1.expect)(amount.subunitValue).toBeEqual(50);
138
- });
139
- });
140
- describe('MoneyAmount.formatted', () => {
141
- it('should format money amount in USD with en locale', () => {
142
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
143
- const config = new Configuration_1.Configuration('USD', 'en');
144
- const formatted = amount.formatted('USD', config);
145
- (0, core_1.expect)(typeof formatted).toBeEqual('string');
146
- (0, core_1.expect)(formatted.length).not.toBeEqual(0);
147
- });
148
- it('should format money amount in EUR with de locale', () => {
149
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
150
- const config = new Configuration_1.Configuration('EUR', 'de');
151
- const formatted = amount.formatted('EUR', config);
152
- (0, core_1.expect)(typeof formatted).toBeEqual('string');
153
- (0, core_1.expect)(formatted.length).not.toBeEqual(0);
154
- });
155
- it('should format zero amount', () => {
156
- const amount = MoneyAmount_1.MoneyAmount.zero;
157
- const config = new Configuration_1.Configuration('USD', 'en');
158
- const formatted = amount.formatted('USD', config);
159
- (0, core_1.expect)(typeof formatted).toBeEqual('string');
160
- (0, core_1.expect)(formatted.length).not.toBeEqual(0);
161
- });
162
- it('should format large amounts', () => {
163
- const amount = new MoneyAmount_1.MoneyAmount(1000, 99);
164
- const config = new Configuration_1.Configuration('USD', 'en');
165
- const formatted = amount.formatted('USD', config);
166
- (0, core_1.expect)(typeof formatted).toBeEqual('string');
167
- (0, core_1.expect)(formatted.includes('1000') || formatted.includes('1,000')).toBeTrue();
168
- });
169
- it('should handle different currencies', () => {
170
- const amount = new MoneyAmount_1.MoneyAmount(15, 75);
171
- const usdConfig = new Configuration_1.Configuration('USD', 'en');
172
- const eurConfig = new Configuration_1.Configuration('EUR', 'de');
173
- const usdFormatted = amount.formatted('USD', usdConfig);
174
- const eurFormatted = amount.formatted('EUR', eurConfig);
175
- (0, core_1.expect)(usdFormatted).not.toBeEqual(eurFormatted);
176
- });
177
- });
178
- describe('MoneyAmount.completeValue', () => {
179
- it('should return complete value as decimal', () => {
180
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
181
- (0, core_1.expect)(amount.completeValue).toBeEqual(10.5);
182
- });
183
- it('should return zero for zero amount', () => {
184
- const amount = MoneyAmount_1.MoneyAmount.zero;
185
- (0, core_1.expect)(amount.completeValue).toBeEqual(0);
186
- });
187
- it('should handle only subunit values', () => {
188
- const amount = new MoneyAmount_1.MoneyAmount(0, 75);
189
- (0, core_1.expect)(amount.completeValue).toBeEqual(0.75);
190
- });
191
- it('should handle whole numbers', () => {
192
- const amount = new MoneyAmount_1.MoneyAmount(15, 0);
193
- (0, core_1.expect)(amount.completeValue).toBeEqual(15);
194
- });
195
- it('should handle 99 subunits', () => {
196
- const amount = new MoneyAmount_1.MoneyAmount(10, 99);
197
- (0, core_1.expect)(amount.completeValue).toBeEqual(10.99);
198
- });
199
- it('should handle single digit subunits', () => {
200
- const amount = new MoneyAmount_1.MoneyAmount(10, 5);
201
- (0, core_1.expect)(amount.completeValue).toBeEqual(10.05);
202
- });
203
- });
204
- describe('MoneyAmount.flatten', () => {
205
- it('should return flattened value as decimal', () => {
206
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
207
- (0, core_1.expect)(amount.flatten).toBeEqual(10.5);
208
- });
209
- it('should flatten zero amount', () => {
210
- const amount = MoneyAmount_1.MoneyAmount.zero;
211
- (0, core_1.expect)(amount.flatten).toBeEqual(0);
212
- });
213
- it('should flatten amount with only subunits', () => {
214
- const amount = new MoneyAmount_1.MoneyAmount(0, 99);
215
- (0, core_1.expect)(amount.flatten).toBeEqual(0.99);
216
- });
217
- it('should match completeValue', () => {
218
- const amount = new MoneyAmount_1.MoneyAmount(15, 75);
219
- (0, core_1.expect)(amount.flatten).toBeEqual(amount.completeValue);
220
- });
221
- it('should return number type', () => {
222
- const amount = new MoneyAmount_1.MoneyAmount(10, 50);
223
- (0, core_1.expect)(typeof amount.flatten).toBeEqual('number');
224
- });
225
- });
226
- describe('MoneyAmount.TypeBuilder', () => {
227
- it('should build money amount from decimal value', () => {
228
- const amount = MoneyAmount_1.MoneyAmount.builder.build(10.5);
229
- (0, core_1.expect)(amount.value).toBeEqual(10);
230
- (0, core_1.expect)(amount.subunitValue).toBeEqual(50);
231
- });
232
- it('should build money amount from zero', () => {
233
- const amount = MoneyAmount_1.MoneyAmount.builder.build(0);
234
- (0, core_1.expect)(amount.value).toBeEqual(0);
235
- (0, core_1.expect)(amount.subunitValue).toBeEqual(0);
236
- });
237
- it('should build money amount from whole number', () => {
238
- const amount = MoneyAmount_1.MoneyAmount.builder.build(15);
239
- (0, core_1.expect)(amount.value).toBeEqual(15);
240
- (0, core_1.expect)(amount.subunitValue).toBeEqual(0);
241
- });
242
- it('should build money amount from small decimal', () => {
243
- const amount = MoneyAmount_1.MoneyAmount.builder.build(0.75);
244
- (0, core_1.expect)(amount.value).toBeEqual(0);
245
- (0, core_1.expect)(amount.subunitValue).toBeEqual(75);
246
- });
247
- it('should build money amount with 99 subunits', () => {
248
- const amount = MoneyAmount_1.MoneyAmount.builder.build(10.99);
249
- (0, core_1.expect)(amount.value).toBeEqual(10);
250
- (0, core_1.expect)(amount.subunitValue).toBeEqual(99);
251
- });
252
- it('should round subunit values properly', () => {
253
- const amount = MoneyAmount_1.MoneyAmount.builder.build(10.555);
254
- (0, core_1.expect)(amount.value).toBeEqual(10);
255
- (0, core_1.expect)(amount.subunitValue).toBeEqual(55);
256
- });
257
- it('should round-trip through flatten and build', () => {
258
- const original = new MoneyAmount_1.MoneyAmount(15, 75);
259
- const rebuilt = MoneyAmount_1.MoneyAmount.builder.build(original.flatten);
260
- (0, core_1.expect)(rebuilt.value).toBeEqual(original.value);
261
- (0, core_1.expect)(rebuilt.subunitValue).toBeEqual(original.subunitValue);
262
- });
263
- it('should round-trip with zero', () => {
264
- const original = MoneyAmount_1.MoneyAmount.zero;
265
- const rebuilt = MoneyAmount_1.MoneyAmount.builder.build(original.flatten);
266
- (0, core_1.expect)(rebuilt.value).toBeEqual(0);
267
- (0, core_1.expect)(rebuilt.subunitValue).toBeEqual(0);
268
- });
269
- it('should round-trip with large values', () => {
270
- const original = new MoneyAmount_1.MoneyAmount(1000, 99);
271
- const rebuilt = MoneyAmount_1.MoneyAmount.builder.build(original.flatten);
272
- (0, core_1.expect)(rebuilt.value).toBeEqual(1000);
273
- (0, core_1.expect)(rebuilt.subunitValue).toBeEqual(99);
274
- });
275
- });
276
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,258 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@assertive-ts/core");
4
- const NotificationProperties_1 = require("../../src/types/NotificationProperties");
5
- const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
6
- describe('NotificationProperties', () => {
7
- describe('NotificationProperties.TokenId', () => {
8
- describe('NotificationProperties.TokenId.create', () => {
9
- it('should create a token ID from a device token', () => {
10
- const token = 'device-token-12345';
11
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create(token);
12
- (0, core_1.expect)(tokenId).not.toBeUndefined();
13
- (0, core_1.expect)(tokenId.flatten.length).toBeEqual(16);
14
- });
15
- it('should create different token IDs for different tokens', () => {
16
- const token1 = 'device-token-abc';
17
- const token2 = 'device-token-xyz';
18
- const tokenId1 = NotificationProperties_1.NotificationProperties.TokenId.create(token1);
19
- const tokenId2 = NotificationProperties_1.NotificationProperties.TokenId.create(token2);
20
- (0, core_1.expect)(tokenId1.flatten).not.toBeEqual(tokenId2.flatten);
21
- });
22
- it('should create consistent token IDs for the same token', () => {
23
- const token = 'consistent-token';
24
- const tokenId1 = NotificationProperties_1.NotificationProperties.TokenId.create(token);
25
- const tokenId2 = NotificationProperties_1.NotificationProperties.TokenId.create(token);
26
- (0, core_1.expect)(tokenId1.flatten).toBeEqual(tokenId2.flatten);
27
- });
28
- it('should create token IDs with hexadecimal characters', () => {
29
- const token = 'test-token';
30
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create(token);
31
- (0, core_1.expect)(tokenId.flatten).toMatchRegex(/^[0-9a-f]{16}$/);
32
- });
33
- it('should handle empty token string', () => {
34
- const token = '';
35
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create(token);
36
- (0, core_1.expect)(tokenId.flatten.length).toBeEqual(16);
37
- });
38
- });
39
- describe('NotificationProperties.TokenId.builder', () => {
40
- it('should build token ID from string', () => {
41
- const tokenIdString = '0123456789abcdef';
42
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.builder.build(tokenIdString);
43
- (0, core_1.expect)(tokenId.flatten).toBeEqual(tokenIdString);
44
- });
45
- it('should preserve token ID value', () => {
46
- const tokenIdString = 'fedcba9876543210';
47
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.builder.build(tokenIdString);
48
- (0, core_1.expect)(tokenId.flatten).toBeEqual(tokenIdString);
49
- });
50
- });
51
- });
52
- describe('NotificationProperties.Subscription', () => {
53
- describe('NotificationProperties.Subscription type', () => {
54
- it('should be valid subscription types', () => {
55
- const sub1 = 'new-fine';
56
- const sub2 = 'fine-reminder';
57
- const sub3 = 'fine-state-change';
58
- (0, core_1.expect)(sub1).toBeEqual('new-fine');
59
- (0, core_1.expect)(sub2).toBeEqual('fine-reminder');
60
- (0, core_1.expect)(sub3).toBeEqual('fine-state-change');
61
- });
62
- });
63
- describe('NotificationProperties.Subscription.all', () => {
64
- it('should contain all subscription types', () => {
65
- (0, core_1.expect)(NotificationProperties_1.NotificationProperties.Subscription.all.length).toBeEqual(3);
66
- });
67
- it('should contain new-fine subscription', () => {
68
- (0, core_1.expect)(NotificationProperties_1.NotificationProperties.Subscription.all.includes('new-fine')).toBeTrue();
69
- });
70
- it('should contain fine-reminder subscription', () => {
71
- (0, core_1.expect)(NotificationProperties_1.NotificationProperties.Subscription.all.includes('fine-reminder')).toBeTrue();
72
- });
73
- it('should contain fine-state-change subscription', () => {
74
- (0, core_1.expect)(NotificationProperties_1.NotificationProperties.Subscription.all.includes('fine-state-change')).toBeTrue();
75
- });
76
- it('should contain only valid subscription strings', () => {
77
- NotificationProperties_1.NotificationProperties.Subscription.all.forEach(subscription => {
78
- (0, core_1.expect)(typeof subscription).toBeEqual('string');
79
- });
80
- });
81
- });
82
- describe('NotificationProperties.Subscription.builder', () => {
83
- it('should build valid subscription from string', () => {
84
- const subscription = NotificationProperties_1.NotificationProperties.Subscription.builder.build('new-fine');
85
- (0, core_1.expect)(subscription).toBeEqual('new-fine');
86
- });
87
- it('should preserve subscription value', () => {
88
- const subscription = NotificationProperties_1.NotificationProperties.Subscription.builder.build('fine-reminder');
89
- (0, core_1.expect)(subscription).toBeEqual('fine-reminder');
90
- });
91
- });
92
- });
93
- describe('NotificationProperties', () => {
94
- describe('NotificationProperties constructor', () => {
95
- it('should create notification properties with empty tokens and subscriptions', () => {
96
- const props = new NotificationProperties_1.NotificationProperties();
97
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(0);
98
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(0);
99
- });
100
- it('should create notification properties with tokens', () => {
101
- const tokens = new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder);
102
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('test-token');
103
- tokens.set(tokenId, 'test-token');
104
- const props = new NotificationProperties_1.NotificationProperties(tokens);
105
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(1);
106
- (0, core_1.expect)(props.tokens.get(tokenId)).toBeEqual('test-token');
107
- });
108
- it('should create notification properties with subscriptions', () => {
109
- const subscriptions = ['new-fine', 'fine-reminder'];
110
- const props = new NotificationProperties_1.NotificationProperties(new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder), subscriptions);
111
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(2);
112
- (0, core_1.expect)(props.subscriptions[0]).toBeEqual('new-fine');
113
- (0, core_1.expect)(props.subscriptions[1]).toBeEqual('fine-reminder');
114
- });
115
- it('should create notification properties with both tokens and subscriptions', () => {
116
- const tokens = new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder);
117
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('device-token');
118
- tokens.set(tokenId, 'device-token');
119
- const subscriptions = ['new-fine'];
120
- const props = new NotificationProperties_1.NotificationProperties(tokens, subscriptions);
121
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(1);
122
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(1);
123
- });
124
- it('should create notification properties with multiple tokens', () => {
125
- const tokens = new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder);
126
- const tokenId1 = NotificationProperties_1.NotificationProperties.TokenId.create('token-1');
127
- const tokenId2 = NotificationProperties_1.NotificationProperties.TokenId.create('token-2');
128
- tokens.set(tokenId1, 'token-1');
129
- tokens.set(tokenId2, 'token-2');
130
- const props = new NotificationProperties_1.NotificationProperties(tokens);
131
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(2);
132
- });
133
- it('should create notification properties with all subscription types', () => {
134
- const subscriptions = ['new-fine', 'fine-reminder', 'fine-state-change'];
135
- const props = new NotificationProperties_1.NotificationProperties(new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder), subscriptions);
136
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(3);
137
- });
138
- });
139
- describe('NotificationProperties.flatten', () => {
140
- it('should return flattened representation with empty tokens and subscriptions', () => {
141
- const props = new NotificationProperties_1.NotificationProperties();
142
- const flattened = props.flatten;
143
- (0, core_1.expect)(Object.keys(flattened.tokens)).toBeEqual([]);
144
- (0, core_1.expect)(flattened.subscriptions.length).toBeEqual(0);
145
- });
146
- it('should return flattened representation with tokens', () => {
147
- const tokens = new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder);
148
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('flatten-token');
149
- tokens.set(tokenId, 'flatten-token');
150
- const props = new NotificationProperties_1.NotificationProperties(tokens);
151
- const flattened = props.flatten;
152
- (0, core_1.expect)(flattened.tokens[tokenId.flatten]).toBeEqual('flatten-token');
153
- });
154
- it('should return flattened representation with subscriptions', () => {
155
- const subscriptions = ['new-fine', 'fine-state-change'];
156
- const props = new NotificationProperties_1.NotificationProperties(new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder), subscriptions);
157
- const flattened = props.flatten;
158
- (0, core_1.expect)(flattened.subscriptions.length).toBeEqual(2);
159
- (0, core_1.expect)(flattened.subscriptions[0]).toBeEqual('new-fine');
160
- (0, core_1.expect)(flattened.subscriptions[1]).toBeEqual('fine-state-change');
161
- });
162
- it('should match the original values', () => {
163
- const tokens = new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder);
164
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('match-token');
165
- tokens.set(tokenId, 'match-token');
166
- const subscriptions = ['fine-reminder'];
167
- const props = new NotificationProperties_1.NotificationProperties(tokens, subscriptions);
168
- const flattened = props.flatten;
169
- (0, core_1.expect)(flattened.subscriptions).toBeEqual(subscriptions);
170
- });
171
- it('should have correct structure', () => {
172
- const props = new NotificationProperties_1.NotificationProperties();
173
- const flattened = props.flatten;
174
- (0, core_1.expect)(typeof flattened.tokens).toBeEqual('object');
175
- (0, core_1.expect)(Array.isArray(flattened.subscriptions)).toBeTrue();
176
- });
177
- });
178
- describe('NotificationProperties.TypeBuilder', () => {
179
- it('should build notification properties from flattened data with empty values', () => {
180
- const flattened = {
181
- tokens: {},
182
- subscriptions: []
183
- };
184
- const props = NotificationProperties_1.NotificationProperties.builder.build(flattened);
185
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(0);
186
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(0);
187
- });
188
- it('should build notification properties from flattened data with tokens', () => {
189
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('build-token');
190
- const flattened = {
191
- tokens: {
192
- [tokenId.flatten]: 'build-token'
193
- },
194
- subscriptions: []
195
- };
196
- const props = NotificationProperties_1.NotificationProperties.builder.build(flattened);
197
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(1);
198
- (0, core_1.expect)(props.tokens.get(tokenId)).toBeEqual('build-token');
199
- });
200
- it('should build notification properties from flattened data with subscriptions', () => {
201
- const flattened = {
202
- tokens: {},
203
- subscriptions: ['new-fine', 'fine-reminder']
204
- };
205
- const props = NotificationProperties_1.NotificationProperties.builder.build(flattened);
206
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(2);
207
- (0, core_1.expect)(props.subscriptions[0]).toBeEqual('new-fine');
208
- });
209
- it('should build notification properties from flattened data with both', () => {
210
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('both-token');
211
- const flattened = {
212
- tokens: {
213
- [tokenId.flatten]: 'both-token'
214
- },
215
- subscriptions: ['fine-state-change']
216
- };
217
- const props = NotificationProperties_1.NotificationProperties.builder.build(flattened);
218
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(1);
219
- (0, core_1.expect)(props.subscriptions.length).toBeEqual(1);
220
- });
221
- it('should round-trip through flatten and build with empty values', () => {
222
- const original = new NotificationProperties_1.NotificationProperties();
223
- const rebuilt = NotificationProperties_1.NotificationProperties.builder.build(original.flatten);
224
- (0, core_1.expect)(rebuilt.tokens.values.length).toBeEqual(original.tokens.values.length);
225
- (0, core_1.expect)(rebuilt.subscriptions.length).toBeEqual(original.subscriptions.length);
226
- });
227
- it('should round-trip through flatten and build with tokens', () => {
228
- const tokens = new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder);
229
- const tokenId = NotificationProperties_1.NotificationProperties.TokenId.create('round-trip-token');
230
- tokens.set(tokenId, 'round-trip-token');
231
- const original = new NotificationProperties_1.NotificationProperties(tokens);
232
- const rebuilt = NotificationProperties_1.NotificationProperties.builder.build(original.flatten);
233
- (0, core_1.expect)(rebuilt.tokens.values.length).toBeEqual(1);
234
- (0, core_1.expect)(rebuilt.tokens.get(tokenId)).toBeEqual('round-trip-token');
235
- });
236
- it('should round-trip through flatten and build with subscriptions', () => {
237
- const subscriptions = ['new-fine', 'fine-reminder', 'fine-state-change'];
238
- const original = new NotificationProperties_1.NotificationProperties(new typescript_common_functionality_1.Dictionary(NotificationProperties_1.NotificationProperties.TokenId.builder), subscriptions);
239
- const rebuilt = NotificationProperties_1.NotificationProperties.builder.build(original.flatten);
240
- (0, core_1.expect)(rebuilt.subscriptions.length).toBeEqual(3);
241
- (0, core_1.expect)(rebuilt.subscriptions).toBeEqual(subscriptions);
242
- });
243
- it('should build with multiple tokens', () => {
244
- const tokenId1 = NotificationProperties_1.NotificationProperties.TokenId.create('multi-token-1');
245
- const tokenId2 = NotificationProperties_1.NotificationProperties.TokenId.create('multi-token-2');
246
- const flattened = {
247
- tokens: {
248
- [tokenId1.flatten]: 'multi-token-1',
249
- [tokenId2.flatten]: 'multi-token-2'
250
- },
251
- subscriptions: []
252
- };
253
- const props = NotificationProperties_1.NotificationProperties.builder.build(flattened);
254
- (0, core_1.expect)(props.tokens.values.length).toBeEqual(2);
255
- });
256
- });
257
- });
258
- });
@@ -1 +0,0 @@
1
- export {};