@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.
- package/lib/src/firebase/FirebaseConfiguration.d.ts +45 -1
- package/lib/src/firebase/FirebaseConfiguration.js +44 -0
- package/lib/src/firebase/Firestore.d.ts +196 -0
- package/lib/src/firebase/Firestore.js +235 -0
- package/lib/src/{FirestoreScheme.d.ts → firebase/FirestoreScheme.d.ts} +15 -1
- package/lib/src/firebase/Messaging.d.ts +64 -0
- package/lib/src/firebase/checkAuthentication.d.ts +37 -0
- package/lib/src/{checkAuthentication.js → firebase/checkAuthentication.js} +26 -1
- package/lib/src/firebase/index.d.ts +4 -0
- package/lib/src/firebase/index.js +4 -0
- package/lib/src/firebase/pushNotification.d.ts +39 -0
- package/lib/src/firebase/pushNotification.js +88 -0
- package/lib/src/functions/fine/add.d.ts +10 -13
- package/lib/src/functions/fine/add.js +3 -30
- package/lib/src/functions/fine/delete.d.ts +10 -13
- package/lib/src/functions/fine/delete.js +3 -27
- package/lib/src/functions/fine/update.d.ts +10 -13
- package/lib/src/functions/fine/update.js +3 -28
- package/lib/src/functions/fineTemplate/add.d.ts +6 -9
- package/lib/src/functions/fineTemplate/add.js +3 -12
- package/lib/src/functions/fineTemplate/delete.d.ts +6 -9
- package/lib/src/functions/fineTemplate/delete.js +3 -12
- package/lib/src/functions/fineTemplate/update.d.ts +6 -9
- package/lib/src/functions/fineTemplate/update.js +3 -12
- package/lib/src/functions/invitation/getInvitation.d.ts +40 -43
- package/lib/src/functions/invitation/getInvitation.js +57 -88
- package/lib/src/functions/invitation/invite.d.ts +1 -2
- package/lib/src/functions/invitation/invite.js +3 -18
- package/lib/src/functions/invitation/register.d.ts +6 -11
- package/lib/src/functions/invitation/register.js +3 -39
- package/lib/src/functions/invitation/withdraw.d.ts +1 -2
- package/lib/src/functions/invitation/withdraw.js +3 -13
- package/lib/src/functions/notification/register.d.ts +7 -10
- package/lib/src/functions/notification/register.js +3 -15
- package/lib/src/functions/notification/subscribe.d.ts +8 -11
- package/lib/src/functions/notification/subscribe.js +3 -14
- package/lib/src/functions/paypalMe/edit.d.ts +6 -9
- package/lib/src/functions/paypalMe/edit.js +3 -14
- package/lib/src/functions/person/add.d.ts +7 -10
- package/lib/src/functions/person/add.js +3 -12
- package/lib/src/functions/person/delete.d.ts +6 -9
- package/lib/src/functions/person/delete.js +3 -14
- package/lib/src/functions/person/update.d.ts +7 -10
- package/lib/src/functions/person/update.js +3 -13
- package/lib/src/functions/team/new.d.ts +9 -12
- package/lib/src/functions/team/new.js +3 -22
- package/lib/src/functions/user/kickout.d.ts +6 -9
- package/lib/src/functions/user/kickout.js +3 -25
- package/lib/src/functions/user/login.d.ts +1 -2
- package/lib/src/functions/user/login.js +3 -13
- package/lib/src/functions/user/roleEdit.d.ts +8 -11
- package/lib/src/functions/user/roleEdit.js +3 -18
- package/lib/src/index.d.ts +0 -5
- package/lib/src/index.js +0 -5
- package/lib/src/locales/de.d.ts +10 -67
- package/lib/src/locales/de.js +8 -0
- package/lib/src/locales/en.d.ts +10 -0
- package/lib/src/locales/en.js +19 -2
- package/lib/src/types/Configuration.d.ts +33 -15
- package/lib/src/types/Configuration.js +24 -12
- package/lib/src/types/Currency.d.ts +20 -0
- package/lib/src/types/Currency.js +19 -0
- package/lib/src/types/Fine.d.ts +41 -0
- package/lib/src/types/Fine.js +32 -0
- package/lib/src/types/FineAmount.d.ts +160 -9
- package/lib/src/types/FineAmount.js +128 -7
- package/lib/src/types/FineTemplate.d.ts +41 -0
- package/lib/src/types/FineTemplate.js +32 -0
- package/lib/src/types/FineTemplateRepetition.d.ts +72 -10
- package/lib/src/types/FineTemplateRepetition.js +66 -12
- package/lib/src/types/Invitation.d.ts +48 -0
- package/lib/src/types/Invitation.js +39 -0
- package/lib/src/types/Locale.d.ts +16 -0
- package/lib/src/types/Locale.js +16 -0
- package/lib/src/types/Localization.d.ts +74 -74
- package/lib/src/types/Localization.js +80 -41
- package/lib/src/types/MoneyAmount.d.ts +67 -1
- package/lib/src/types/MoneyAmount.js +62 -0
- package/lib/src/types/NotificationProperties.d.ts +70 -9
- package/lib/src/types/NotificationProperties.js +49 -5
- package/lib/src/types/PayedState.d.ts +25 -9
- package/lib/src/types/PayedState.js +17 -27
- package/lib/src/types/Person.d.ts +45 -0
- package/lib/src/types/Person.js +36 -0
- package/lib/src/types/PersonPrivateProperties.d.ts +28 -0
- package/lib/src/types/PersonPrivateProperties.js +25 -0
- package/lib/src/types/PersonSignInProperties.d.ts +30 -0
- package/lib/src/types/PersonSignInProperties.js +27 -0
- package/lib/src/types/Pluralization.d.ts +46 -0
- package/lib/src/types/Pluralization.js +46 -0
- package/lib/src/types/Team.d.ts +38 -0
- package/lib/src/types/Team.js +29 -0
- package/lib/src/types/User.d.ts +68 -3
- package/lib/src/types/User.js +59 -5
- package/lib/src/types/UserRole.d.ts +26 -4
- package/lib/src/types/UserRole.js +25 -9
- package/lib/src/types/index.d.ts +2 -0
- package/lib/src/types/index.js +2 -0
- package/lib/test/firebase/FirebaseConfiguration.test.js +155 -0
- package/lib/test/firebase/Firestore.test.js +46 -0
- package/lib/test/firebase/checkAuthentication.test.d.ts +1 -0
- package/lib/test/firebase/checkAuthentication.test.js +305 -0
- package/lib/test/firebase/firebase-utils.d.ts +32 -0
- package/lib/test/firebase/firebase-utils.js +131 -0
- package/lib/test/firebase/pushNotification.test.d.ts +1 -0
- package/lib/test/firebase/pushNotification.test.js +300 -0
- package/lib/test/locales/localization.de.test.d.ts +1 -0
- package/lib/test/locales/localization.de.test.js +144 -0
- package/lib/test/locales/localization.en.test.d.ts +1 -0
- package/lib/test/locales/localization.en.test.js +144 -0
- package/lib/test/types/Configuration.test.d.ts +1 -0
- package/lib/test/types/Configuration.test.js +84 -0
- package/lib/test/types/Currency.test.d.ts +1 -0
- package/lib/test/types/Currency.test.js +41 -0
- package/lib/test/types/Fine.test.d.ts +1 -0
- package/lib/test/types/Fine.test.js +265 -0
- package/lib/test/types/FineAmount.test.d.ts +1 -0
- package/lib/test/types/FineAmount.test.js +445 -0
- package/lib/test/types/FineTemplate.test.d.ts +1 -0
- package/lib/test/types/FineTemplate.test.js +271 -0
- package/lib/test/types/FineTemplateRepetition.test.d.ts +1 -0
- package/lib/test/types/FineTemplateRepetition.test.js +361 -0
- package/lib/test/types/Invitation.test.d.ts +1 -0
- package/lib/test/types/Invitation.test.js +269 -0
- package/lib/test/types/Locale.test.d.ts +1 -0
- package/lib/test/types/Locale.test.js +46 -0
- package/lib/test/types/Localization.test.d.ts +1 -0
- package/lib/test/types/Localization.test.js +241 -0
- package/lib/test/types/MoneyAmount.test.d.ts +1 -0
- package/lib/test/types/MoneyAmount.test.js +276 -0
- package/lib/test/types/NotificationProperties.test.d.ts +1 -0
- package/lib/test/types/NotificationProperties.test.js +258 -0
- package/lib/test/types/PayedState.test.d.ts +1 -0
- package/lib/test/types/PayedState.test.js +105 -0
- package/lib/test/types/Person.test.d.ts +1 -0
- package/lib/test/types/Person.test.js +266 -0
- package/lib/test/types/PersonPrivateProperties.test.d.ts +1 -0
- package/lib/test/types/PersonPrivateProperties.test.js +155 -0
- package/lib/test/types/PersonSignInProperties.test.d.ts +1 -0
- package/lib/test/types/PersonSignInProperties.test.js +208 -0
- package/lib/test/types/Pluralization.test.d.ts +1 -0
- package/lib/test/types/Pluralization.test.js +206 -0
- package/lib/test/types/Team.test.d.ts +1 -0
- package/lib/test/types/Team.test.js +145 -0
- package/lib/test/types/User.test.d.ts +1 -0
- package/lib/test/types/User.test.js +232 -0
- package/lib/test/types/UserRole.test.d.ts +1 -0
- package/lib/test/types/UserRole.test.js +140 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/src/firebase/FirebaseConfiguration.ts +49 -1
- package/src/firebase/Firestore.ts +248 -0
- package/src/{FirestoreScheme.ts → firebase/FirestoreScheme.ts} +15 -1
- package/src/firebase/Messaging.ts +64 -0
- package/src/{checkAuthentication.ts → firebase/checkAuthentication.ts} +39 -1
- package/src/firebase/index.ts +5 -0
- package/src/firebase/pushNotification.ts +90 -0
- package/src/functions/fine/add.ts +10 -48
- package/src/functions/fine/delete.ts +9 -43
- package/src/functions/fine/update.ts +10 -44
- package/src/functions/fineTemplate/add.ts +7 -23
- package/src/functions/fineTemplate/delete.ts +7 -23
- package/src/functions/fineTemplate/update.ts +7 -24
- package/src/functions/index.ts +0 -1
- package/src/functions/invitation/getInvitation.ts +81 -118
- package/src/functions/invitation/invite.ts +2 -25
- package/src/functions/invitation/register.ts +9 -60
- package/src/functions/invitation/withdraw.ts +2 -16
- package/src/functions/notification/register.ts +7 -26
- package/src/functions/notification/subscribe.ts +8 -26
- package/src/functions/paypalMe/edit.ts +7 -25
- package/src/functions/person/add.ts +8 -24
- package/src/functions/person/delete.ts +6 -25
- package/src/functions/person/update.ts +8 -25
- package/src/functions/team/new.ts +12 -42
- package/src/functions/user/kickout.ts +8 -41
- package/src/functions/user/login.ts +2 -16
- package/src/functions/user/roleEdit.ts +8 -32
- package/src/index.ts +0 -5
- package/src/locales/de.ts +10 -1
- package/src/locales/en.ts +21 -2
- package/src/types/Configuration.ts +33 -23
- package/src/types/Currency.ts +24 -0
- package/src/types/Fine.ts +41 -0
- package/src/types/FineAmount.ts +162 -11
- package/src/types/FineTemplate.ts +41 -0
- package/src/types/FineTemplateRepetition.ts +75 -17
- package/src/types/Invitation.ts +48 -0
- package/src/types/Locale.ts +20 -0
- package/src/types/Localization.ts +96 -41
- package/src/types/MoneyAmount.ts +67 -1
- package/src/types/NotificationProperties.ts +67 -9
- package/src/types/PayedState.ts +25 -30
- package/src/types/Person.ts +45 -0
- package/src/types/PersonPrivateProperties.ts +28 -1
- package/src/types/PersonSignInProperties.ts +30 -0
- package/src/types/Pluralization.ts +46 -0
- package/src/types/Team.ts +38 -0
- package/src/types/User.ts +70 -4
- package/src/types/UserRole.ts +32 -16
- package/src/types/index.ts +2 -0
- package/lib/src/Firestore.d.ts +0 -24
- package/lib/src/Firestore.js +0 -62
- package/lib/src/checkAuthentication.d.ts +0 -6
- package/lib/src/firebaseFunctionsContext.d.ts +0 -39
- package/lib/src/firebaseFunctionsContext.js +0 -43
- package/lib/src/pushNotification.d.ts +0 -3
- package/lib/src/pushNotification.js +0 -35
- package/lib/test/localization-utils.d.ts +0 -1
- package/lib/test/localization-utils.js +0 -24
- package/lib/test/localization.de.test.js +0 -151
- package/lib/test/localization.en.test.js +0 -145
- package/src/Firestore.ts +0 -75
- package/src/firebaseFunctionsContext.ts +0 -48
- package/src/pushNotification.ts +0 -37
- /package/lib/src/{FirestoreScheme.js → firebase/FirestoreScheme.js} +0 -0
- /package/lib/test/{localization.de.test.d.ts → firebase/FirebaseConfiguration.test.d.ts} +0 -0
- /package/lib/test/{localization.en.test.d.ts → firebase/Firestore.test.d.ts} +0 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const Pluralization_1 = require("../../src/types/Pluralization");
|
|
5
|
+
describe('Pluralization', () => {
|
|
6
|
+
describe('Pluralization constructor', () => {
|
|
7
|
+
it('should create pluralization with only other form', () => {
|
|
8
|
+
const plural = new Pluralization_1.Pluralization({
|
|
9
|
+
other: 'items'
|
|
10
|
+
});
|
|
11
|
+
(0, core_1.expect)(plural.get(10)).toBeEqual('items');
|
|
12
|
+
});
|
|
13
|
+
it('should create pluralization with all forms', () => {
|
|
14
|
+
const plural = new Pluralization_1.Pluralization({
|
|
15
|
+
zero: 'no items',
|
|
16
|
+
one: 'one item',
|
|
17
|
+
two: 'two items',
|
|
18
|
+
few: 'few items',
|
|
19
|
+
many: 'many items',
|
|
20
|
+
other: 'some items'
|
|
21
|
+
});
|
|
22
|
+
(0, core_1.expect)(plural.get(0)).toBeEqual('no items');
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('Pluralization.get with zero form', () => {
|
|
26
|
+
it('should return zero form for count = 0', () => {
|
|
27
|
+
const plural = new Pluralization_1.Pluralization({
|
|
28
|
+
zero: 'no items',
|
|
29
|
+
other: 'items'
|
|
30
|
+
});
|
|
31
|
+
(0, core_1.expect)(plural.get(0)).toBeEqual('no items');
|
|
32
|
+
});
|
|
33
|
+
it('should return other form for count = 0 when zero not defined', () => {
|
|
34
|
+
const plural = new Pluralization_1.Pluralization({
|
|
35
|
+
other: 'items'
|
|
36
|
+
});
|
|
37
|
+
(0, core_1.expect)(plural.get(0)).toBeEqual('items');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe('Pluralization.get with one form', () => {
|
|
41
|
+
it('should return one form for count = 1', () => {
|
|
42
|
+
const plural = new Pluralization_1.Pluralization({
|
|
43
|
+
one: 'one item',
|
|
44
|
+
other: 'items'
|
|
45
|
+
});
|
|
46
|
+
(0, core_1.expect)(plural.get(1)).toBeEqual('one item');
|
|
47
|
+
});
|
|
48
|
+
it('should return other form for count = 1 when one not defined', () => {
|
|
49
|
+
const plural = new Pluralization_1.Pluralization({
|
|
50
|
+
other: 'items'
|
|
51
|
+
});
|
|
52
|
+
(0, core_1.expect)(plural.get(1)).toBeEqual('items');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe('Pluralization.get with two form', () => {
|
|
56
|
+
it('should return two form for count = 2', () => {
|
|
57
|
+
const plural = new Pluralization_1.Pluralization({
|
|
58
|
+
two: 'two items',
|
|
59
|
+
other: 'items'
|
|
60
|
+
});
|
|
61
|
+
(0, core_1.expect)(plural.get(2)).toBeEqual('two items');
|
|
62
|
+
});
|
|
63
|
+
it('should return other form for count = 2 when two not defined', () => {
|
|
64
|
+
const plural = new Pluralization_1.Pluralization({
|
|
65
|
+
other: 'items'
|
|
66
|
+
});
|
|
67
|
+
(0, core_1.expect)(plural.get(2)).toBeEqual('items');
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe('Pluralization.get with few form', () => {
|
|
71
|
+
it('should return few form for count = 3', () => {
|
|
72
|
+
const plural = new Pluralization_1.Pluralization({
|
|
73
|
+
few: 'few items',
|
|
74
|
+
other: 'items'
|
|
75
|
+
});
|
|
76
|
+
(0, core_1.expect)(plural.get(3)).toBeEqual('few items');
|
|
77
|
+
});
|
|
78
|
+
it('should return few form for count = 4', () => {
|
|
79
|
+
const plural = new Pluralization_1.Pluralization({
|
|
80
|
+
few: 'few items',
|
|
81
|
+
other: 'items'
|
|
82
|
+
});
|
|
83
|
+
(0, core_1.expect)(plural.get(4)).toBeEqual('few items');
|
|
84
|
+
});
|
|
85
|
+
it('should return other form for count = 3 when few not defined', () => {
|
|
86
|
+
const plural = new Pluralization_1.Pluralization({
|
|
87
|
+
other: 'items'
|
|
88
|
+
});
|
|
89
|
+
(0, core_1.expect)(plural.get(3)).toBeEqual('items');
|
|
90
|
+
});
|
|
91
|
+
it('should not use few form for count = 1', () => {
|
|
92
|
+
const plural = new Pluralization_1.Pluralization({
|
|
93
|
+
few: 'few items',
|
|
94
|
+
other: 'items'
|
|
95
|
+
});
|
|
96
|
+
(0, core_1.expect)(plural.get(1)).toBeEqual('items');
|
|
97
|
+
});
|
|
98
|
+
it('should use few form for count = 2 when two form not defined', () => {
|
|
99
|
+
const plural = new Pluralization_1.Pluralization({
|
|
100
|
+
few: 'few items',
|
|
101
|
+
other: 'items'
|
|
102
|
+
});
|
|
103
|
+
(0, core_1.expect)(plural.get(2)).toBeEqual('few items');
|
|
104
|
+
});
|
|
105
|
+
it('should not use few form for count = 5', () => {
|
|
106
|
+
const plural = new Pluralization_1.Pluralization({
|
|
107
|
+
few: 'few items',
|
|
108
|
+
other: 'items'
|
|
109
|
+
});
|
|
110
|
+
(0, core_1.expect)(plural.get(5)).toBeEqual('items');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('Pluralization.get with many form', () => {
|
|
114
|
+
it('should return many form for count = 5', () => {
|
|
115
|
+
const plural = new Pluralization_1.Pluralization({
|
|
116
|
+
many: 'many items',
|
|
117
|
+
other: 'items'
|
|
118
|
+
});
|
|
119
|
+
(0, core_1.expect)(plural.get(5)).toBeEqual('many items');
|
|
120
|
+
});
|
|
121
|
+
it('should return many form for count = 10', () => {
|
|
122
|
+
const plural = new Pluralization_1.Pluralization({
|
|
123
|
+
many: 'many items',
|
|
124
|
+
other: 'items'
|
|
125
|
+
});
|
|
126
|
+
(0, core_1.expect)(plural.get(10)).toBeEqual('many items');
|
|
127
|
+
});
|
|
128
|
+
it('should return many form for count = 20', () => {
|
|
129
|
+
const plural = new Pluralization_1.Pluralization({
|
|
130
|
+
many: 'many items',
|
|
131
|
+
other: 'items'
|
|
132
|
+
});
|
|
133
|
+
(0, core_1.expect)(plural.get(20)).toBeEqual('many items');
|
|
134
|
+
});
|
|
135
|
+
it('should return other form for count = 5 when many not defined', () => {
|
|
136
|
+
const plural = new Pluralization_1.Pluralization({
|
|
137
|
+
other: 'items'
|
|
138
|
+
});
|
|
139
|
+
(0, core_1.expect)(plural.get(5)).toBeEqual('items');
|
|
140
|
+
});
|
|
141
|
+
it('should not use many form for count = 4', () => {
|
|
142
|
+
const plural = new Pluralization_1.Pluralization({
|
|
143
|
+
many: 'many items',
|
|
144
|
+
other: 'items'
|
|
145
|
+
});
|
|
146
|
+
(0, core_1.expect)(plural.get(4)).toBeEqual('items');
|
|
147
|
+
});
|
|
148
|
+
it('should not use many form for count = 21', () => {
|
|
149
|
+
const plural = new Pluralization_1.Pluralization({
|
|
150
|
+
many: 'many items',
|
|
151
|
+
other: 'items'
|
|
152
|
+
});
|
|
153
|
+
(0, core_1.expect)(plural.get(21)).toBeEqual('items');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
describe('Pluralization.get with other form', () => {
|
|
157
|
+
it('should return other form for large count', () => {
|
|
158
|
+
const plural = new Pluralization_1.Pluralization({
|
|
159
|
+
other: 'items'
|
|
160
|
+
});
|
|
161
|
+
(0, core_1.expect)(plural.get(100)).toBeEqual('items');
|
|
162
|
+
});
|
|
163
|
+
it('should return other form when no specific form matches', () => {
|
|
164
|
+
const plural = new Pluralization_1.Pluralization({
|
|
165
|
+
zero: 'no items',
|
|
166
|
+
one: 'one item',
|
|
167
|
+
other: 'items'
|
|
168
|
+
});
|
|
169
|
+
(0, core_1.expect)(plural.get(50)).toBeEqual('items');
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
describe('Pluralization.get with all forms defined', () => {
|
|
173
|
+
it('should select correct form based on priority', () => {
|
|
174
|
+
const plural = new Pluralization_1.Pluralization({
|
|
175
|
+
zero: 'zero',
|
|
176
|
+
one: 'one',
|
|
177
|
+
two: 'two',
|
|
178
|
+
few: 'few',
|
|
179
|
+
many: 'many',
|
|
180
|
+
other: 'other'
|
|
181
|
+
});
|
|
182
|
+
(0, core_1.expect)(plural.get(0)).toBeEqual('zero');
|
|
183
|
+
(0, core_1.expect)(plural.get(1)).toBeEqual('one');
|
|
184
|
+
(0, core_1.expect)(plural.get(2)).toBeEqual('two');
|
|
185
|
+
(0, core_1.expect)(plural.get(3)).toBeEqual('few');
|
|
186
|
+
(0, core_1.expect)(plural.get(4)).toBeEqual('few');
|
|
187
|
+
(0, core_1.expect)(plural.get(5)).toBeEqual('many');
|
|
188
|
+
(0, core_1.expect)(plural.get(10)).toBeEqual('many');
|
|
189
|
+
(0, core_1.expect)(plural.get(20)).toBeEqual('many');
|
|
190
|
+
(0, core_1.expect)(plural.get(21)).toBeEqual('other');
|
|
191
|
+
(0, core_1.expect)(plural.get(100)).toBeEqual('other');
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
describe('Pluralization.get with template strings', () => {
|
|
195
|
+
it('should handle template-style strings', () => {
|
|
196
|
+
const plural = new Pluralization_1.Pluralization({
|
|
197
|
+
zero: 'You have no messages',
|
|
198
|
+
one: 'You have {{count}} message',
|
|
199
|
+
other: 'You have {{count}} messages'
|
|
200
|
+
});
|
|
201
|
+
(0, core_1.expect)(plural.get(0)).toBeEqual('You have no messages');
|
|
202
|
+
(0, core_1.expect)(plural.get(1)).toBeEqual('You have {{count}} message');
|
|
203
|
+
(0, core_1.expect)(plural.get(5)).toBeEqual('You have {{count}} messages');
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const Team_1 = require("../../src/types/Team");
|
|
5
|
+
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
6
|
+
describe('Team', () => {
|
|
7
|
+
describe('Team.Id', () => {
|
|
8
|
+
describe('Team.Id type', () => {
|
|
9
|
+
it('should create a valid team ID', () => {
|
|
10
|
+
const guidString = typescript_common_functionality_1.Guid.generate().guidString;
|
|
11
|
+
const teamId = Team_1.Team.Id.builder.build(guidString);
|
|
12
|
+
(0, core_1.expect)(teamId.value.guidString).toBeEqual(guidString);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('Team.Id.builder', () => {
|
|
16
|
+
it('should build team ID from GUID string', () => {
|
|
17
|
+
const guidString = 'a2345678-1234-4234-1234-123456789abc';
|
|
18
|
+
const teamId = Team_1.Team.Id.builder.build(guidString);
|
|
19
|
+
(0, core_1.expect)(teamId.value.guidString).toBeEqual(guidString);
|
|
20
|
+
});
|
|
21
|
+
it('should preserve team ID value', () => {
|
|
22
|
+
const guidString = 'abcdef01-3456-4890-abcd-ef1234567890';
|
|
23
|
+
const teamId = Team_1.Team.Id.builder.build(guidString);
|
|
24
|
+
(0, core_1.expect)(teamId.flatten).toBeEqual(guidString);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('Team', () => {
|
|
29
|
+
describe('Team constructor', () => {
|
|
30
|
+
it('should create a team with ID, name, and PayPal link', () => {
|
|
31
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
32
|
+
const team = new Team_1.Team(teamId, 'Alpha Team', 'https://paypal.me/alphateam');
|
|
33
|
+
(0, core_1.expect)(team.id).toBeEqual(teamId);
|
|
34
|
+
(0, core_1.expect)(team.name).toBeEqual('Alpha Team');
|
|
35
|
+
(0, core_1.expect)(team.paypalMeLink).toBeEqual('https://paypal.me/alphateam');
|
|
36
|
+
});
|
|
37
|
+
it('should create a team without PayPal link', () => {
|
|
38
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
39
|
+
const team = new Team_1.Team(teamId, 'Beta Team', null);
|
|
40
|
+
(0, core_1.expect)(team.id).toBeEqual(teamId);
|
|
41
|
+
(0, core_1.expect)(team.name).toBeEqual('Beta Team');
|
|
42
|
+
(0, core_1.expect)(team.paypalMeLink).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
it('should create teams with different names', () => {
|
|
45
|
+
const teamId1 = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
46
|
+
const teamId2 = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
47
|
+
const team1 = new Team_1.Team(teamId1, 'Team One', null);
|
|
48
|
+
const team2 = new Team_1.Team(teamId2, 'Team Two', 'https://paypal.me/team2');
|
|
49
|
+
(0, core_1.expect)(team1.name).toBeEqual('Team One');
|
|
50
|
+
(0, core_1.expect)(team2.name).toBeEqual('Team Two');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe('Team.flatten', () => {
|
|
54
|
+
it('should return flattened representation with PayPal link', () => {
|
|
55
|
+
const guidString = 'a1111111-1111-4111-1111-111111111111';
|
|
56
|
+
const teamId = Team_1.Team.Id.builder.build(guidString);
|
|
57
|
+
const team = new Team_1.Team(teamId, 'Flatten Team', 'https://paypal.me/flattenteam');
|
|
58
|
+
const flattened = team.flatten;
|
|
59
|
+
(0, core_1.expect)(flattened.id).toBeEqual(guidString);
|
|
60
|
+
(0, core_1.expect)(flattened.name).toBeEqual('Flatten Team');
|
|
61
|
+
(0, core_1.expect)(flattened.paypalMeLink).toBeEqual('https://paypal.me/flattenteam');
|
|
62
|
+
});
|
|
63
|
+
it('should return flattened representation without PayPal link', () => {
|
|
64
|
+
const guidString = 'a2222222-2222-4222-2222-222222222222';
|
|
65
|
+
const teamId = Team_1.Team.Id.builder.build(guidString);
|
|
66
|
+
const team = new Team_1.Team(teamId, 'No PayPal Team', null);
|
|
67
|
+
const flattened = team.flatten;
|
|
68
|
+
(0, core_1.expect)(flattened.id).toBeEqual(guidString);
|
|
69
|
+
(0, core_1.expect)(flattened.name).toBeEqual('No PayPal Team');
|
|
70
|
+
(0, core_1.expect)(flattened.paypalMeLink).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
it('should match the original values', () => {
|
|
73
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
74
|
+
const name = 'Match Team';
|
|
75
|
+
const paypalLink = 'https://paypal.me/match';
|
|
76
|
+
const team = new Team_1.Team(teamId, name, paypalLink);
|
|
77
|
+
const flattened = team.flatten;
|
|
78
|
+
(0, core_1.expect)(flattened.id).toBeEqual(teamId.flatten);
|
|
79
|
+
(0, core_1.expect)(flattened.name).toBeEqual(name);
|
|
80
|
+
(0, core_1.expect)(flattened.paypalMeLink).toBeEqual(paypalLink);
|
|
81
|
+
});
|
|
82
|
+
it('should have correct structure', () => {
|
|
83
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
84
|
+
const team = new Team_1.Team(teamId, 'Structure Team', null);
|
|
85
|
+
const flattened = team.flatten;
|
|
86
|
+
(0, core_1.expect)(typeof flattened.id).toBeEqual('string');
|
|
87
|
+
(0, core_1.expect)(typeof flattened.name).toBeEqual('string');
|
|
88
|
+
(0, core_1.expect)(flattened.paypalMeLink).toBeNull();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe('Team.TypeBuilder', () => {
|
|
92
|
+
it('should build team from flattened data with PayPal link', () => {
|
|
93
|
+
const flattened = {
|
|
94
|
+
id: 'a3333333-3333-4333-3333-333333333333',
|
|
95
|
+
name: 'Built Team',
|
|
96
|
+
paypalMeLink: 'https://paypal.me/builtteam'
|
|
97
|
+
};
|
|
98
|
+
const team = Team_1.Team.builder.build(flattened);
|
|
99
|
+
(0, core_1.expect)(team.id.value.guidString).toBeEqual('a3333333-3333-4333-3333-333333333333');
|
|
100
|
+
(0, core_1.expect)(team.name).toBeEqual('Built Team');
|
|
101
|
+
(0, core_1.expect)(team.paypalMeLink).toBeEqual('https://paypal.me/builtteam');
|
|
102
|
+
});
|
|
103
|
+
it('should build team from flattened data without PayPal link', () => {
|
|
104
|
+
const flattened = {
|
|
105
|
+
id: 'a4444444-4444-4444-4444-444444444444',
|
|
106
|
+
name: 'No Link Team',
|
|
107
|
+
paypalMeLink: null
|
|
108
|
+
};
|
|
109
|
+
const team = Team_1.Team.builder.build(flattened);
|
|
110
|
+
(0, core_1.expect)(team.id.value.guidString).toBeEqual('a4444444-4444-4444-4444-444444444444');
|
|
111
|
+
(0, core_1.expect)(team.name).toBeEqual('No Link Team');
|
|
112
|
+
(0, core_1.expect)(team.paypalMeLink).toBeNull();
|
|
113
|
+
});
|
|
114
|
+
it('should round-trip through flatten and build with PayPal link', () => {
|
|
115
|
+
const teamId = Team_1.Team.Id.builder.build('a5555555-5555-4555-5555-555555555555');
|
|
116
|
+
const original = new Team_1.Team(teamId, 'Round Trip Team', 'https://paypal.me/roundtrip');
|
|
117
|
+
const rebuilt = Team_1.Team.builder.build(original.flatten);
|
|
118
|
+
(0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
|
|
119
|
+
(0, core_1.expect)(rebuilt.name).toBeEqual(original.name);
|
|
120
|
+
(0, core_1.expect)(rebuilt.paypalMeLink).toBeEqual(original.paypalMeLink);
|
|
121
|
+
});
|
|
122
|
+
it('should round-trip through flatten and build without PayPal link', () => {
|
|
123
|
+
const teamId = Team_1.Team.Id.builder.build('a6666666-6666-4666-6666-666666666666');
|
|
124
|
+
const original = new Team_1.Team(teamId, 'Null Link Team', null);
|
|
125
|
+
const rebuilt = Team_1.Team.builder.build(original.flatten);
|
|
126
|
+
(0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
|
|
127
|
+
(0, core_1.expect)(rebuilt.name).toBeEqual(original.name);
|
|
128
|
+
(0, core_1.expect)(rebuilt.paypalMeLink).toBeNull();
|
|
129
|
+
});
|
|
130
|
+
it('should build teams with various valid inputs', () => {
|
|
131
|
+
const testCases = [
|
|
132
|
+
{ id: 'a7777777-7777-4777-7777-777777777777', name: 'Test 1', paypalMeLink: 'https://paypal.me/test1' },
|
|
133
|
+
{ id: 'a8888888-8888-4888-8888-888888888888', name: 'Test 2', paypalMeLink: null },
|
|
134
|
+
{ id: 'a9999999-9999-4999-9999-999999999999', name: 'Team with Long Name', paypalMeLink: 'https://paypal.me/longname' }
|
|
135
|
+
];
|
|
136
|
+
testCases.forEach(testCase => {
|
|
137
|
+
const team = Team_1.Team.builder.build(testCase);
|
|
138
|
+
(0, core_1.expect)(team.id.value.guidString).toBeEqual(testCase.id);
|
|
139
|
+
(0, core_1.expect)(team.name).toBeEqual(testCase.name);
|
|
140
|
+
(0, core_1.expect)(team.paypalMeLink).toBeEqual(testCase.paypalMeLink);
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const User_1 = require("../../src/types/User");
|
|
5
|
+
const Team_1 = require("../../src/types/Team");
|
|
6
|
+
const Person_1 = require("../../src/types/Person");
|
|
7
|
+
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
8
|
+
describe('User', () => {
|
|
9
|
+
describe('User.Id', () => {
|
|
10
|
+
describe('User.Id type', () => {
|
|
11
|
+
it('should create a valid user ID', () => {
|
|
12
|
+
const userId = User_1.User.Id.builder.build('user-123');
|
|
13
|
+
(0, core_1.expect)(userId.value).toBeEqual('user-123');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('User.Id.builder', () => {
|
|
17
|
+
it('should build user ID from string', () => {
|
|
18
|
+
const userId = User_1.User.Id.builder.build('test-user-id');
|
|
19
|
+
(0, core_1.expect)(userId.value).toBeEqual('test-user-id');
|
|
20
|
+
});
|
|
21
|
+
it('should preserve user ID value', () => {
|
|
22
|
+
const originalId = 'abc-def-123';
|
|
23
|
+
const userId = User_1.User.Id.builder.build(originalId);
|
|
24
|
+
(0, core_1.expect)(userId.flatten).toBeEqual(originalId);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe('User.TeamProperties', () => {
|
|
29
|
+
describe('User.TeamProperties constructor', () => {
|
|
30
|
+
it('should create team properties with team name and person ID', () => {
|
|
31
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
32
|
+
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
33
|
+
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Alpha', personId);
|
|
34
|
+
(0, core_1.expect)(teamProperties.teamId).toBeEqual(teamId);
|
|
35
|
+
(0, core_1.expect)(teamProperties.teamName).toBeEqual('Team Alpha');
|
|
36
|
+
(0, core_1.expect)(teamProperties.personId).toBeEqual(personId);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
describe('User.TeamProperties.flatten', () => {
|
|
40
|
+
it('should return flattened representation', () => {
|
|
41
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
42
|
+
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
43
|
+
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Beta', personId);
|
|
44
|
+
const flattened = teamProperties.flatten;
|
|
45
|
+
(0, core_1.expect)(flattened.teamId).toBeEqual(teamId.guidString);
|
|
46
|
+
(0, core_1.expect)(flattened.teamName).toBeEqual('Team Beta');
|
|
47
|
+
(0, core_1.expect)(flattened.personId).toBeEqual(personId.guidString);
|
|
48
|
+
});
|
|
49
|
+
it('should match the original values', () => {
|
|
50
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
51
|
+
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
52
|
+
const teamName = 'Team Gamma';
|
|
53
|
+
const teamProperties = new User_1.User.TeamProperties(teamId, teamName, personId);
|
|
54
|
+
const flattened = teamProperties.flatten;
|
|
55
|
+
(0, core_1.expect)(flattened.teamId).toBeEqual(teamId.flatten);
|
|
56
|
+
(0, core_1.expect)(flattened.teamName).toBeEqual(teamName);
|
|
57
|
+
(0, core_1.expect)(flattened.personId).toBeEqual(personId.flatten);
|
|
58
|
+
});
|
|
59
|
+
it('should have correct structure', () => {
|
|
60
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
61
|
+
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
62
|
+
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Delta', personId);
|
|
63
|
+
const flattened = teamProperties.flatten;
|
|
64
|
+
(0, core_1.expect)(typeof flattened.teamId).toBeEqual('string');
|
|
65
|
+
(0, core_1.expect)(typeof flattened.teamName).toBeEqual('string');
|
|
66
|
+
(0, core_1.expect)(typeof flattened.personId).toBeEqual('string');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('User.TeamProperties.TypeBuilder', () => {
|
|
70
|
+
it('should build team properties from flattened data', () => {
|
|
71
|
+
const flattened = {
|
|
72
|
+
teamId: '87654321-4321-4321-4321-210987654321',
|
|
73
|
+
teamName: 'Team Epsilon',
|
|
74
|
+
personId: '12345678-1234-4234-1234-123456789012'
|
|
75
|
+
};
|
|
76
|
+
const teamProperties = User_1.User.TeamProperties.builder.build(flattened);
|
|
77
|
+
(0, core_1.expect)(teamProperties.teamId.value.guidString).toBeEqual('87654321-4321-4321-4321-210987654321');
|
|
78
|
+
(0, core_1.expect)(teamProperties.teamName).toBeEqual('Team Epsilon');
|
|
79
|
+
(0, core_1.expect)(teamProperties.personId.value.guidString).toBeEqual('12345678-1234-4234-1234-123456789012');
|
|
80
|
+
});
|
|
81
|
+
it('should round-trip through flatten and build', () => {
|
|
82
|
+
const teamId = Team_1.Team.Id.builder.build('12345678-1234-4234-1234-123456789012');
|
|
83
|
+
const personId = Person_1.Person.Id.builder.build('87654321-4321-4321-4321-210987654321');
|
|
84
|
+
const original = new User_1.User.TeamProperties(teamId, 'Team Zeta', personId);
|
|
85
|
+
const rebuilt = User_1.User.TeamProperties.builder.build(original.flatten);
|
|
86
|
+
(0, core_1.expect)(rebuilt.teamId.flatten).toBeEqual(original.teamId.flatten);
|
|
87
|
+
(0, core_1.expect)(rebuilt.teamName).toBeEqual(original.teamName);
|
|
88
|
+
(0, core_1.expect)(rebuilt.personId.flatten).toBeEqual(original.personId.flatten);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
describe('User', () => {
|
|
93
|
+
describe('User constructor', () => {
|
|
94
|
+
it('should create a user with ID and empty teams dictionary', () => {
|
|
95
|
+
const userId = User_1.User.Id.builder.build('user-001');
|
|
96
|
+
const user = new User_1.User(userId);
|
|
97
|
+
(0, core_1.expect)(user.id).toBeEqual(userId);
|
|
98
|
+
(0, core_1.expect)(user.teams.values.length).toBeEqual(0);
|
|
99
|
+
});
|
|
100
|
+
it('should create a user with ID and teams', () => {
|
|
101
|
+
const userId = User_1.User.Id.builder.build('user-002');
|
|
102
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
103
|
+
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
104
|
+
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team A', personId);
|
|
105
|
+
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
106
|
+
teams.set(teamId, teamProperties);
|
|
107
|
+
const user = new User_1.User(userId, teams);
|
|
108
|
+
(0, core_1.expect)(user.id).toBeEqual(userId);
|
|
109
|
+
(0, core_1.expect)(user.teams.values.length).toBeEqual(1);
|
|
110
|
+
(0, core_1.expect)(user.teams.get(teamId)?.teamName).toBeEqual('Team A');
|
|
111
|
+
});
|
|
112
|
+
it('should create a user with multiple teams', () => {
|
|
113
|
+
const userId = User_1.User.Id.builder.build('user-003');
|
|
114
|
+
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
115
|
+
const teamId1 = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
116
|
+
const personId1 = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
117
|
+
teams.set(teamId1, new User_1.User.TeamProperties(teamId1, 'Team One', personId1));
|
|
118
|
+
const teamId2 = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
119
|
+
const personId2 = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
120
|
+
teams.set(teamId2, new User_1.User.TeamProperties(teamId2, 'Team Two', personId2));
|
|
121
|
+
const user = new User_1.User(userId, teams);
|
|
122
|
+
(0, core_1.expect)(user.teams.values.length).toBeEqual(2);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
describe('User.flatten', () => {
|
|
126
|
+
it('should return flattened representation with empty teams', () => {
|
|
127
|
+
const userId = User_1.User.Id.builder.build('user-flat-001');
|
|
128
|
+
const user = new User_1.User(userId);
|
|
129
|
+
const flattened = user.flatten;
|
|
130
|
+
(0, core_1.expect)(flattened.id).toBeEqual('user-flat-001');
|
|
131
|
+
(0, core_1.expect)(Object.keys(flattened.teams)).toBeEqual([]);
|
|
132
|
+
});
|
|
133
|
+
it('should return flattened representation with teams', () => {
|
|
134
|
+
const userId = User_1.User.Id.builder.build('user-flat-002');
|
|
135
|
+
const teamId = Team_1.Team.Id.builder.build('11111111-1111-4111-1111-111111111111');
|
|
136
|
+
const personId = Person_1.Person.Id.builder.build('22222222-2222-4222-2222-222222222222');
|
|
137
|
+
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Flatten', personId);
|
|
138
|
+
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
139
|
+
teams.set(teamId, teamProperties);
|
|
140
|
+
const user = new User_1.User(userId, teams);
|
|
141
|
+
const flattened = user.flatten;
|
|
142
|
+
(0, core_1.expect)(flattened.id).toBeEqual('user-flat-002');
|
|
143
|
+
(0, core_1.expect)(flattened.teams['11111111-1111-4111-1111-111111111111']).not.toBeUndefined();
|
|
144
|
+
(0, core_1.expect)(flattened.teams['11111111-1111-4111-1111-111111111111'].teamName).toBeEqual('Team Flatten');
|
|
145
|
+
});
|
|
146
|
+
it('should match the original values', () => {
|
|
147
|
+
const userId = User_1.User.Id.builder.build('user-match-001');
|
|
148
|
+
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
149
|
+
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
150
|
+
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
151
|
+
teams.set(teamId, new User_1.User.TeamProperties(teamId, 'Match Team', personId));
|
|
152
|
+
const user = new User_1.User(userId, teams);
|
|
153
|
+
const flattened = user.flatten;
|
|
154
|
+
(0, core_1.expect)(flattened.id).toBeEqual(userId.flatten);
|
|
155
|
+
});
|
|
156
|
+
it('should have correct structure', () => {
|
|
157
|
+
const userId = User_1.User.Id.builder.build('user-struct-001');
|
|
158
|
+
const user = new User_1.User(userId);
|
|
159
|
+
const flattened = user.flatten;
|
|
160
|
+
(0, core_1.expect)(typeof flattened.id).toBeEqual('string');
|
|
161
|
+
(0, core_1.expect)(typeof flattened.teams).toBeEqual('object');
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
describe('User.TypeBuilder', () => {
|
|
165
|
+
it('should build user from flattened data with empty teams', () => {
|
|
166
|
+
const flattened = {
|
|
167
|
+
id: 'user-build-001',
|
|
168
|
+
teams: {}
|
|
169
|
+
};
|
|
170
|
+
const user = User_1.User.builder.build(flattened);
|
|
171
|
+
(0, core_1.expect)(user.id.flatten).toBeEqual('user-build-001');
|
|
172
|
+
(0, core_1.expect)(user.teams.values.length).toBeEqual(0);
|
|
173
|
+
});
|
|
174
|
+
it('should build user from flattened data with teams', () => {
|
|
175
|
+
const flattened = {
|
|
176
|
+
id: 'user-build-002',
|
|
177
|
+
teams: {
|
|
178
|
+
'33333333-3333-4333-3333-333333333333': {
|
|
179
|
+
teamId: '33333333-3333-4333-3333-333333333333',
|
|
180
|
+
teamName: 'Built Team',
|
|
181
|
+
personId: '44444444-4444-4444-4444-444444444444'
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const user = User_1.User.builder.build(flattened);
|
|
186
|
+
(0, core_1.expect)(user.id.flatten).toBeEqual('user-build-002');
|
|
187
|
+
(0, core_1.expect)(user.teams.values.length).toBeEqual(1);
|
|
188
|
+
const teamId = Team_1.Team.Id.builder.build('33333333-3333-4333-3333-333333333333');
|
|
189
|
+
(0, core_1.expect)(user.teams.get(teamId)?.teamName).toBeEqual('Built Team');
|
|
190
|
+
});
|
|
191
|
+
it('should round-trip through flatten and build with empty teams', () => {
|
|
192
|
+
const userId = User_1.User.Id.builder.build('user-round-001');
|
|
193
|
+
const original = new User_1.User(userId);
|
|
194
|
+
const rebuilt = User_1.User.builder.build(original.flatten);
|
|
195
|
+
(0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
|
|
196
|
+
(0, core_1.expect)(rebuilt.teams.values.length).toBeEqual(original.teams.values.length);
|
|
197
|
+
});
|
|
198
|
+
it('should round-trip through flatten and build with teams', () => {
|
|
199
|
+
const userId = User_1.User.Id.builder.build('user-round-002');
|
|
200
|
+
const teamId = Team_1.Team.Id.builder.build('55555555-5555-4555-5555-555555555555');
|
|
201
|
+
const personId = Person_1.Person.Id.builder.build('66666666-6666-4666-6666-666666666666');
|
|
202
|
+
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
203
|
+
teams.set(teamId, new User_1.User.TeamProperties(teamId, 'Round Trip Team', personId));
|
|
204
|
+
const original = new User_1.User(userId, teams);
|
|
205
|
+
const rebuilt = User_1.User.builder.build(original.flatten);
|
|
206
|
+
(0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
|
|
207
|
+
(0, core_1.expect)(rebuilt.teams.values.length).toBeEqual(original.teams.values.length);
|
|
208
|
+
(0, core_1.expect)(rebuilt.teams.get(teamId)?.teamName).toBeEqual('Round Trip Team');
|
|
209
|
+
(0, core_1.expect)(rebuilt.teams.get(teamId)?.personId.flatten).toBeEqual(personId.flatten);
|
|
210
|
+
});
|
|
211
|
+
it('should build user with multiple teams', () => {
|
|
212
|
+
const flattened = {
|
|
213
|
+
id: 'user-multi-001',
|
|
214
|
+
teams: {
|
|
215
|
+
'77777777-7777-4777-7777-777777777777': {
|
|
216
|
+
teamId: '77777777-7777-4777-7777-777777777777',
|
|
217
|
+
teamName: 'Multi Team 1',
|
|
218
|
+
personId: '88888888-8888-4888-8888-888888888888'
|
|
219
|
+
},
|
|
220
|
+
'99999999-9999-4999-9999-999999999999': {
|
|
221
|
+
teamId: '99999999-9999-4999-9999-999999999999',
|
|
222
|
+
teamName: 'Multi Team 2',
|
|
223
|
+
personId: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaaaa'
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const user = User_1.User.builder.build(flattened);
|
|
228
|
+
(0, core_1.expect)(user.teams.values.length).toBeEqual(2);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|