@stevenkellner/team-conduct-api 2.0.18 → 2.0.20
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/functions/fine/add.d.ts +3 -8
- package/lib/src/functions/fine/add.js +1 -2
- package/lib/src/functions/fine/delete.d.ts +1 -6
- package/lib/src/functions/fine/delete.js +2 -3
- package/lib/src/functions/fine/update.d.ts +2 -8
- package/lib/src/functions/fine/update.js +1 -3
- package/lib/src/functions/fineTemplate/add.d.ts +3 -3
- package/lib/src/functions/fineTemplate/update.d.ts +3 -3
- package/lib/src/functions/firebaseFunctionsContext.d.ts +34 -1
- package/lib/src/functions/firebaseFunctionsContext.js +33 -33
- package/lib/src/functions/index.d.ts +10 -8
- package/lib/src/functions/index.js +11 -8
- package/lib/src/functions/notification/markNotificationAsRead.d.ts +14 -0
- package/lib/src/functions/notification/{subscribe.js → markNotificationAsRead.js} +5 -7
- package/lib/src/functions/person/kickout.d.ts +6 -6
- package/lib/src/functions/person/kickout.js +4 -4
- package/lib/src/functions/person/roleEdit.d.ts +5 -5
- package/lib/src/functions/person/roleEdit.js +3 -3
- package/lib/src/functions/{paypalMe/edit.d.ts → team/delete.d.ts} +5 -7
- package/lib/src/functions/{paypalMe/edit.js → team/delete.js} +4 -5
- package/lib/src/functions/team/new.d.ts +18 -18
- package/lib/src/functions/team/new.js +8 -4
- package/lib/src/functions/team/update.d.ts +34 -0
- package/lib/src/functions/team/update.js +23 -0
- package/lib/src/functions/user/register.d.ts +4 -0
- package/lib/src/functions/user/register.js +3 -1
- package/lib/src/functions/user/update.d.ts +26 -0
- package/lib/src/functions/user/update.js +15 -0
- package/lib/src/index.d.ts +1 -1
- package/lib/src/index.js +1 -1
- package/lib/src/locales/de.d.ts +1 -1
- package/lib/src/locales/de.js +6 -2
- package/lib/src/locales/en.d.ts +6 -2
- package/lib/src/locales/en.js +6 -2
- package/lib/src/types/{MoneyAmount.d.ts → Money.d.ts} +23 -23
- package/lib/src/types/{MoneyAmount.js → Money.js} +25 -25
- package/lib/src/types/fine/Fine.d.ts +275 -0
- package/lib/src/types/fine/Fine.js +318 -0
- package/lib/src/types/fine/FineTemplate.d.ts +154 -0
- package/lib/src/types/fine/FineTemplate.js +170 -0
- package/lib/src/types/{PayedState.d.ts → fine/PayedState.d.ts} +1 -1
- package/lib/src/types/{PayedState.js → fine/PayedState.js} +1 -1
- package/lib/src/types/fine/index.d.ts +3 -0
- package/lib/src/{firebase → types/fine}/index.js +3 -6
- package/lib/src/types/index.d.ts +7 -18
- package/lib/src/types/index.js +7 -18
- package/lib/src/types/{Localization.d.ts → localization/Localization.d.ts} +15 -43
- package/lib/src/types/localization/Localization.js +54 -0
- package/lib/src/types/localization/PluralLocalization.d.ts +23 -0
- package/lib/src/types/localization/PluralLocalization.js +35 -0
- package/lib/src/types/{Pluralization.d.ts → localization/Pluralization.d.ts} +1 -0
- package/lib/src/types/{Pluralization.js → localization/Pluralization.js} +1 -0
- package/lib/src/types/localization/ValueLocalization.d.ts +22 -0
- package/lib/src/types/localization/ValueLocalization.js +41 -0
- package/lib/src/types/localization/index.d.ts +5 -0
- package/lib/src/types/localization/index.js +21 -0
- package/lib/src/types/notification/InAppNotification.d.ts +152 -0
- package/lib/src/types/notification/InAppNotification.js +136 -0
- package/lib/src/types/notification/index.d.ts +1 -0
- package/lib/src/types/notification/index.js +17 -0
- package/lib/src/types/{Person.d.ts → person/Person.d.ts} +3 -3
- package/lib/src/types/{Person.js → person/Person.js} +3 -3
- package/lib/src/types/{PersonProperties.d.ts → person/PersonProperties.d.ts} +8 -7
- package/lib/src/types/{PersonProperties.js → person/PersonProperties.js} +7 -6
- package/lib/src/types/{PersonSignInProperties.d.ts → person/PersonSignInProperties.d.ts} +9 -11
- package/lib/src/types/{PersonSignInProperties.js → person/PersonSignInProperties.js} +7 -10
- package/lib/src/types/person/index.d.ts +3 -0
- package/lib/src/types/person/index.js +19 -0
- package/lib/src/types/{Invitation.d.ts → team/Invitation.d.ts} +1 -1
- package/lib/src/types/{Invitation.js → team/Invitation.js} +1 -1
- package/lib/src/types/team/Team.d.ts +144 -0
- package/lib/src/types/team/Team.js +141 -0
- package/lib/src/types/team/TeamRole.d.ts +30 -0
- package/lib/src/types/{UserRole.js → team/TeamRole.js} +16 -15
- package/lib/src/types/team/index.d.ts +3 -0
- package/lib/src/types/team/index.js +19 -0
- package/lib/src/types/{NotificationProperties.d.ts → user/NotificationProperties.d.ts} +8 -3
- package/lib/src/types/{NotificationProperties.js → user/NotificationProperties.js} +4 -0
- package/lib/src/types/user/User.d.ts +328 -0
- package/lib/src/types/user/User.js +355 -0
- package/lib/src/types/user/index.d.ts +2 -0
- package/lib/src/types/user/index.js +18 -0
- package/lib/src/utils/StaticUnionTypeBuilder.d.ts +9 -0
- package/lib/src/utils/StaticUnionTypeBuilder.js +23 -0
- package/lib/src/utils/index.d.ts +1 -0
- package/lib/src/utils/index.js +17 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -3
- package/src/functions/fine/add.ts +3 -5
- package/src/functions/fine/delete.ts +3 -5
- package/src/functions/fine/update.ts +2 -5
- package/src/functions/firebaseFunctionsContext.ts +40 -40
- package/src/functions/index.ts +11 -9
- package/src/functions/notification/markNotificationAsRead.ts +19 -0
- package/src/functions/person/add.ts +1 -1
- package/src/functions/person/kickout.ts +6 -6
- package/src/functions/person/roleEdit.ts +5 -5
- package/src/functions/{paypalMe/edit.ts → team/delete.ts} +5 -7
- package/src/functions/team/new.ts +19 -11
- package/src/functions/team/update.ts +40 -0
- package/src/functions/user/register.ts +7 -3
- package/src/functions/user/update.ts +29 -0
- package/src/index.ts +1 -1
- package/src/locales/de.ts +7 -3
- package/src/locales/en.ts +7 -3
- package/src/types/{MoneyAmount.ts → Money.ts} +29 -29
- package/src/types/fine/Fine.ts +399 -0
- package/src/types/fine/FineTemplate.ts +219 -0
- package/src/types/{PayedState.ts → fine/PayedState.ts} +2 -2
- package/src/types/fine/index.ts +3 -0
- package/src/types/index.ts +7 -18
- package/src/types/{Localization.ts → localization/Localization.ts} +7 -64
- package/src/types/localization/PluralLocalization.ts +32 -0
- package/src/types/{Pluralization.ts → localization/Pluralization.ts} +1 -0
- package/src/types/localization/ValueLocalization.ts +36 -0
- package/src/types/localization/index.ts +5 -0
- package/src/types/notification/InAppNotification.ts +184 -0
- package/src/types/notification/index.ts +1 -0
- package/src/types/{Person.ts → person/Person.ts} +3 -3
- package/src/types/{PersonProperties.ts → person/PersonProperties.ts} +8 -7
- package/src/types/{PersonSignInProperties.ts → person/PersonSignInProperties.ts} +13 -12
- package/src/types/person/index.ts +3 -0
- package/src/types/{Invitation.ts → team/Invitation.ts} +1 -1
- package/src/types/team/Team.ts +204 -0
- package/src/types/{UserRole.ts → team/TeamRole.ts} +19 -17
- package/src/types/team/index.ts +3 -0
- package/src/types/{NotificationProperties.ts → user/NotificationProperties.ts} +12 -3
- package/src/types/user/User.ts +451 -0
- package/src/types/user/index.ts +2 -0
- package/src/utils/StaticUnionTypeBuilder.ts +23 -0
- package/src/utils/index.ts +1 -0
- package/lib/src/firebase/FirebaseConfiguration.d.ts +0 -64
- package/lib/src/firebase/FirebaseConfiguration.js +0 -79
- package/lib/src/firebase/Firestore.d.ts +0 -201
- package/lib/src/firebase/Firestore.js +0 -244
- package/lib/src/firebase/FirestoreScheme.d.ts +0 -42
- package/lib/src/firebase/FirestoreScheme.js +0 -2
- package/lib/src/firebase/Messaging.d.ts +0 -90
- package/lib/src/firebase/Messaging.js +0 -2
- package/lib/src/firebase/checkAuthentication.d.ts +0 -38
- package/lib/src/firebase/checkAuthentication.js +0 -64
- package/lib/src/firebase/index.d.ts +0 -6
- package/lib/src/firebase/pushNotification.d.ts +0 -39
- package/lib/src/firebase/pushNotification.js +0 -88
- package/lib/src/functions/notification/subscribe.d.ts +0 -18
- package/lib/src/types/Configuration.d.ts +0 -46
- package/lib/src/types/Configuration.js +0 -51
- package/lib/src/types/Fine.d.ts +0 -71
- package/lib/src/types/Fine.js +0 -74
- package/lib/src/types/FineAmount.d.ts +0 -207
- package/lib/src/types/FineAmount.js +0 -238
- package/lib/src/types/FineTemplate.d.ts +0 -69
- package/lib/src/types/FineTemplate.js +0 -72
- package/lib/src/types/FineTemplateRepetition.d.ts +0 -87
- package/lib/src/types/FineTemplateRepetition.js +0 -103
- package/lib/src/types/Localization.js +0 -115
- package/lib/src/types/Team.d.ts +0 -62
- package/lib/src/types/Team.js +0 -64
- package/lib/src/types/User.d.ts +0 -221
- package/lib/src/types/User.js +0 -235
- package/lib/src/types/UserRole.d.ts +0 -29
- package/lib/test/firebase/FirebaseConfiguration.test.d.ts +0 -1
- package/lib/test/firebase/FirebaseConfiguration.test.js +0 -158
- package/lib/test/firebase/Firestore.test.d.ts +0 -1
- package/lib/test/firebase/Firestore.test.js +0 -46
- package/lib/test/firebase/checkAuthentication.test.d.ts +0 -1
- package/lib/test/firebase/checkAuthentication.test.js +0 -356
- package/lib/test/firebase/firebase-utils.d.ts +0 -32
- package/lib/test/firebase/firebase-utils.js +0 -134
- package/lib/test/firebase/pushNotification.test.d.ts +0 -1
- package/lib/test/firebase/pushNotification.test.js +0 -300
- package/lib/test/locales/localization.de.test.d.ts +0 -1
- package/lib/test/locales/localization.de.test.js +0 -144
- package/lib/test/locales/localization.en.test.d.ts +0 -1
- package/lib/test/locales/localization.en.test.js +0 -144
- package/lib/test/types/Configuration.test.d.ts +0 -1
- package/lib/test/types/Configuration.test.js +0 -84
- package/lib/test/types/Currency.test.d.ts +0 -1
- package/lib/test/types/Currency.test.js +0 -41
- package/lib/test/types/Fine.test.d.ts +0 -1
- package/lib/test/types/Fine.test.js +0 -265
- package/lib/test/types/FineAmount.test.d.ts +0 -1
- package/lib/test/types/FineAmount.test.js +0 -445
- package/lib/test/types/FineTemplate.test.d.ts +0 -1
- package/lib/test/types/FineTemplate.test.js +0 -271
- package/lib/test/types/FineTemplateRepetition.test.d.ts +0 -1
- package/lib/test/types/FineTemplateRepetition.test.js +0 -361
- package/lib/test/types/Invitation.test.d.ts +0 -1
- package/lib/test/types/Invitation.test.js +0 -269
- package/lib/test/types/Locale.test.d.ts +0 -1
- package/lib/test/types/Locale.test.js +0 -46
- package/lib/test/types/Localization.test.d.ts +0 -1
- package/lib/test/types/Localization.test.js +0 -241
- package/lib/test/types/MoneyAmount.test.d.ts +0 -1
- package/lib/test/types/MoneyAmount.test.js +0 -276
- package/lib/test/types/NotificationProperties.test.d.ts +0 -1
- package/lib/test/types/NotificationProperties.test.js +0 -258
- package/lib/test/types/PayedState.test.d.ts +0 -1
- package/lib/test/types/PayedState.test.js +0 -136
- package/lib/test/types/Person.test.d.ts +0 -1
- package/lib/test/types/Person.test.js +0 -266
- package/lib/test/types/PersonProperties.test.d.ts +0 -1
- package/lib/test/types/PersonProperties.test.js +0 -155
- package/lib/test/types/PersonSignInProperties.test.d.ts +0 -1
- package/lib/test/types/PersonSignInProperties.test.js +0 -208
- package/lib/test/types/Pluralization.test.d.ts +0 -1
- package/lib/test/types/Pluralization.test.js +0 -206
- package/lib/test/types/Team.test.d.ts +0 -1
- package/lib/test/types/Team.test.js +0 -145
- package/lib/test/types/User.test.d.ts +0 -1
- package/lib/test/types/User.test.js +0 -450
- package/lib/test/types/UserRole.test.d.ts +0 -1
- package/lib/test/types/UserRole.test.js +0 -140
- package/src/firebase/FirebaseConfiguration.ts +0 -99
- package/src/firebase/Firestore.ts +0 -258
- package/src/firebase/FirestoreScheme.ts +0 -41
- package/src/firebase/Messaging.ts +0 -93
- package/src/firebase/checkAuthentication.ts +0 -91
- package/src/firebase/index.ts +0 -7
- package/src/firebase/pushNotification.ts +0 -90
- package/src/functions/notification/subscribe.ts +0 -23
- package/src/types/Configuration.ts +0 -65
- package/src/types/Fine.ts +0 -100
- package/src/types/FineAmount.ts +0 -303
- package/src/types/FineTemplate.ts +0 -96
- package/src/types/FineTemplateRepetition.ts +0 -125
- package/src/types/Team.ts +0 -87
- package/src/types/User.ts +0 -302
- /package/lib/src/types/{Locale.d.ts → localization/Locale.d.ts} +0 -0
- /package/lib/src/types/{Locale.js → localization/Locale.js} +0 -0
- /package/src/types/{Locale.ts → localization/Locale.ts} +0 -0
|
@@ -1,450 +0,0 @@
|
|
|
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.SignInTypeEmail', () => {
|
|
29
|
-
describe('User.SignInTypeEmail constructor', () => {
|
|
30
|
-
it('should create email sign-in type with email', () => {
|
|
31
|
-
const signInType = new User_1.User.SignInTypeEmail('test@example.com');
|
|
32
|
-
(0, core_1.expect)(signInType.email).toBeEqual('test@example.com');
|
|
33
|
-
});
|
|
34
|
-
it('should create email sign-in type with different emails', () => {
|
|
35
|
-
const signInType1 = new User_1.User.SignInTypeEmail('user1@test.com');
|
|
36
|
-
const signInType2 = new User_1.User.SignInTypeEmail('user2@test.com');
|
|
37
|
-
(0, core_1.expect)(signInType1.email).toBeEqual('user1@test.com');
|
|
38
|
-
(0, core_1.expect)(signInType2.email).toBeEqual('user2@test.com');
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('User.SignInTypeEmail.flatten', () => {
|
|
42
|
-
it('should return flattened representation with email type', () => {
|
|
43
|
-
const signInType = new User_1.User.SignInTypeEmail('flatten@test.com');
|
|
44
|
-
const flattened = signInType.flatten;
|
|
45
|
-
(0, core_1.expect)(flattened.type).toBeEqual('email');
|
|
46
|
-
(0, core_1.expect)(flattened.email).toBeEqual('flatten@test.com');
|
|
47
|
-
});
|
|
48
|
-
it('should preserve email value', () => {
|
|
49
|
-
const email = 'preserve@example.com';
|
|
50
|
-
const signInType = new User_1.User.SignInTypeEmail(email);
|
|
51
|
-
(0, core_1.expect)(signInType.flatten.email).toBeEqual(email);
|
|
52
|
-
});
|
|
53
|
-
it('should have correct structure', () => {
|
|
54
|
-
const signInType = new User_1.User.SignInTypeEmail('struct@test.com');
|
|
55
|
-
const flattened = signInType.flatten;
|
|
56
|
-
(0, core_1.expect)(typeof flattened.type).toBeEqual('string');
|
|
57
|
-
(0, core_1.expect)(typeof flattened.email).toBeEqual('string');
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('User.SignInTypeEmail.TypeBuilder', () => {
|
|
61
|
-
it('should build from flattened data', () => {
|
|
62
|
-
const flattened = {
|
|
63
|
-
type: 'email',
|
|
64
|
-
email: 'build@test.com'
|
|
65
|
-
};
|
|
66
|
-
const signInType = User_1.User.SignInTypeEmail.builder.build(flattened);
|
|
67
|
-
(0, core_1.expect)(signInType.email).toBeEqual('build@test.com');
|
|
68
|
-
});
|
|
69
|
-
it('should round-trip through flatten and build', () => {
|
|
70
|
-
const original = new User_1.User.SignInTypeEmail('roundtrip@test.com');
|
|
71
|
-
const rebuilt = User_1.User.SignInTypeEmail.builder.build(original.flatten);
|
|
72
|
-
(0, core_1.expect)(rebuilt.email).toBeEqual(original.email);
|
|
73
|
-
});
|
|
74
|
-
it('should handle various email formats', () => {
|
|
75
|
-
const emails = ['simple@test.com', 'with.dot@test.com', 'with+plus@test.com'];
|
|
76
|
-
emails.forEach(email => {
|
|
77
|
-
const flattened = { type: 'email', email };
|
|
78
|
-
const signInType = User_1.User.SignInTypeEmail.builder.build(flattened);
|
|
79
|
-
(0, core_1.expect)(signInType.email).toBeEqual(email);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('User.SignInTypeOAuth', () => {
|
|
85
|
-
describe('User.SignInTypeOAuth constructor', () => {
|
|
86
|
-
it('should create OAuth sign-in type with google provider', () => {
|
|
87
|
-
const signInType = new User_1.User.SignInTypeOAuth('google');
|
|
88
|
-
(0, core_1.expect)(signInType.provider).toBeEqual('google');
|
|
89
|
-
});
|
|
90
|
-
it('should create OAuth sign-in type with apple provider', () => {
|
|
91
|
-
const signInType = new User_1.User.SignInTypeOAuth('apple');
|
|
92
|
-
(0, core_1.expect)(signInType.provider).toBeEqual('apple');
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('User.SignInTypeOAuth.flatten', () => {
|
|
96
|
-
it('should return flattened representation with google type', () => {
|
|
97
|
-
const signInType = new User_1.User.SignInTypeOAuth('google');
|
|
98
|
-
const flattened = signInType.flatten;
|
|
99
|
-
(0, core_1.expect)(flattened.type).toBeEqual('google');
|
|
100
|
-
});
|
|
101
|
-
it('should return flattened representation with apple type', () => {
|
|
102
|
-
const signInType = new User_1.User.SignInTypeOAuth('apple');
|
|
103
|
-
const flattened = signInType.flatten;
|
|
104
|
-
(0, core_1.expect)(flattened.type).toBeEqual('apple');
|
|
105
|
-
});
|
|
106
|
-
it('should preserve provider value', () => {
|
|
107
|
-
const signInType1 = new User_1.User.SignInTypeOAuth('google');
|
|
108
|
-
const signInType2 = new User_1.User.SignInTypeOAuth('apple');
|
|
109
|
-
(0, core_1.expect)(signInType1.flatten.type).toBeEqual('google');
|
|
110
|
-
(0, core_1.expect)(signInType2.flatten.type).toBeEqual('apple');
|
|
111
|
-
});
|
|
112
|
-
it('should have correct structure', () => {
|
|
113
|
-
const signInType = new User_1.User.SignInTypeOAuth('google');
|
|
114
|
-
const flattened = signInType.flatten;
|
|
115
|
-
(0, core_1.expect)(typeof flattened.type).toBeEqual('string');
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
describe('User.SignInTypeOAuth.TypeBuilder', () => {
|
|
119
|
-
it('should build from flattened data with google', () => {
|
|
120
|
-
const flattened = { type: 'google' };
|
|
121
|
-
const signInType = User_1.User.SignInTypeOAuth.builder.build(flattened);
|
|
122
|
-
(0, core_1.expect)(signInType.provider).toBeEqual('google');
|
|
123
|
-
});
|
|
124
|
-
it('should build from flattened data with apple', () => {
|
|
125
|
-
const flattened = { type: 'apple' };
|
|
126
|
-
const signInType = User_1.User.SignInTypeOAuth.builder.build(flattened);
|
|
127
|
-
(0, core_1.expect)(signInType.provider).toBeEqual('apple');
|
|
128
|
-
});
|
|
129
|
-
it('should round-trip through flatten and build for google', () => {
|
|
130
|
-
const original = new User_1.User.SignInTypeOAuth('google');
|
|
131
|
-
const rebuilt = User_1.User.SignInTypeOAuth.builder.build(original.flatten);
|
|
132
|
-
(0, core_1.expect)(rebuilt.provider).toBeEqual(original.provider);
|
|
133
|
-
});
|
|
134
|
-
it('should round-trip through flatten and build for apple', () => {
|
|
135
|
-
const original = new User_1.User.SignInTypeOAuth('apple');
|
|
136
|
-
const rebuilt = User_1.User.SignInTypeOAuth.builder.build(original.flatten);
|
|
137
|
-
(0, core_1.expect)(rebuilt.provider).toBeEqual(original.provider);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
describe('User.SignInType', () => {
|
|
142
|
-
describe('User.SignInType.TypeBuilder', () => {
|
|
143
|
-
it('should build email sign-in type from flattened data', () => {
|
|
144
|
-
const flattened = {
|
|
145
|
-
type: 'email',
|
|
146
|
-
email: 'union@test.com'
|
|
147
|
-
};
|
|
148
|
-
const signInType = User_1.User.SignInType.builder.build(flattened);
|
|
149
|
-
(0, core_1.expect)(signInType instanceof User_1.User.SignInTypeEmail).toBeTrue();
|
|
150
|
-
if (signInType instanceof User_1.User.SignInTypeEmail)
|
|
151
|
-
(0, core_1.expect)(signInType.email).toBeEqual('union@test.com');
|
|
152
|
-
});
|
|
153
|
-
it('should build google OAuth sign-in type from flattened data', () => {
|
|
154
|
-
const flattened = { type: 'google' };
|
|
155
|
-
const signInType = User_1.User.SignInType.builder.build(flattened);
|
|
156
|
-
(0, core_1.expect)(signInType instanceof User_1.User.SignInTypeOAuth).toBeTrue();
|
|
157
|
-
if (signInType instanceof User_1.User.SignInTypeOAuth)
|
|
158
|
-
(0, core_1.expect)(signInType.provider).toBeEqual('google');
|
|
159
|
-
});
|
|
160
|
-
it('should build apple OAuth sign-in type from flattened data', () => {
|
|
161
|
-
const flattened = { type: 'apple' };
|
|
162
|
-
const signInType = User_1.User.SignInType.builder.build(flattened);
|
|
163
|
-
(0, core_1.expect)(signInType instanceof User_1.User.SignInTypeOAuth).toBeTrue();
|
|
164
|
-
if (signInType instanceof User_1.User.SignInTypeOAuth)
|
|
165
|
-
(0, core_1.expect)(signInType.provider).toBeEqual('apple');
|
|
166
|
-
});
|
|
167
|
-
it('should round-trip email sign-in type', () => {
|
|
168
|
-
const original = new User_1.User.SignInTypeEmail('roundtrip@test.com');
|
|
169
|
-
const rebuilt = User_1.User.SignInType.builder.build(original.flatten);
|
|
170
|
-
(0, core_1.expect)(rebuilt instanceof User_1.User.SignInTypeEmail).toBeTrue();
|
|
171
|
-
if (rebuilt instanceof User_1.User.SignInTypeEmail)
|
|
172
|
-
(0, core_1.expect)(rebuilt.email).toBeEqual(original.email);
|
|
173
|
-
});
|
|
174
|
-
it('should round-trip OAuth sign-in type', () => {
|
|
175
|
-
const original = new User_1.User.SignInTypeOAuth('google');
|
|
176
|
-
const rebuilt = User_1.User.SignInType.builder.build(original.flatten);
|
|
177
|
-
(0, core_1.expect)(rebuilt instanceof User_1.User.SignInTypeOAuth).toBeTrue();
|
|
178
|
-
if (rebuilt instanceof User_1.User.SignInTypeOAuth)
|
|
179
|
-
(0, core_1.expect)(rebuilt.provider).toBeEqual(original.provider);
|
|
180
|
-
});
|
|
181
|
-
it('should handle all sign-in types', () => {
|
|
182
|
-
const signInTypes = [
|
|
183
|
-
new User_1.User.SignInTypeEmail('all@test.com'),
|
|
184
|
-
new User_1.User.SignInTypeOAuth('google'),
|
|
185
|
-
new User_1.User.SignInTypeOAuth('apple')
|
|
186
|
-
];
|
|
187
|
-
signInTypes.forEach(signInType => {
|
|
188
|
-
const rebuilt = User_1.User.SignInType.builder.build(signInType.flatten);
|
|
189
|
-
(0, core_1.expect)(rebuilt.flatten).toBeEqual(signInType.flatten);
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
describe('User.TeamProperties', () => {
|
|
195
|
-
describe('User.TeamProperties constructor', () => {
|
|
196
|
-
it('should create team properties with team name and person ID', () => {
|
|
197
|
-
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
198
|
-
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
199
|
-
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Alpha', personId);
|
|
200
|
-
(0, core_1.expect)(teamProperties.teamId).toBeEqual(teamId);
|
|
201
|
-
(0, core_1.expect)(teamProperties.teamName).toBeEqual('Team Alpha');
|
|
202
|
-
(0, core_1.expect)(teamProperties.personId).toBeEqual(personId);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
describe('User.TeamProperties.flatten', () => {
|
|
206
|
-
it('should return flattened representation', () => {
|
|
207
|
-
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
208
|
-
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
209
|
-
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Beta', personId);
|
|
210
|
-
const flattened = teamProperties.flatten;
|
|
211
|
-
(0, core_1.expect)(flattened.teamId).toBeEqual(teamId.guidString);
|
|
212
|
-
(0, core_1.expect)(flattened.teamName).toBeEqual('Team Beta');
|
|
213
|
-
(0, core_1.expect)(flattened.personId).toBeEqual(personId.guidString);
|
|
214
|
-
});
|
|
215
|
-
it('should match the original values', () => {
|
|
216
|
-
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
217
|
-
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
218
|
-
const teamName = 'Team Gamma';
|
|
219
|
-
const teamProperties = new User_1.User.TeamProperties(teamId, teamName, personId);
|
|
220
|
-
const flattened = teamProperties.flatten;
|
|
221
|
-
(0, core_1.expect)(flattened.teamId).toBeEqual(teamId.flatten);
|
|
222
|
-
(0, core_1.expect)(flattened.teamName).toBeEqual(teamName);
|
|
223
|
-
(0, core_1.expect)(flattened.personId).toBeEqual(personId.flatten);
|
|
224
|
-
});
|
|
225
|
-
it('should have correct structure', () => {
|
|
226
|
-
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
227
|
-
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
228
|
-
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Delta', personId);
|
|
229
|
-
const flattened = teamProperties.flatten;
|
|
230
|
-
(0, core_1.expect)(typeof flattened.teamId).toBeEqual('string');
|
|
231
|
-
(0, core_1.expect)(typeof flattened.teamName).toBeEqual('string');
|
|
232
|
-
(0, core_1.expect)(typeof flattened.personId).toBeEqual('string');
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
describe('User.TeamProperties.TypeBuilder', () => {
|
|
236
|
-
it('should build team properties from flattened data', () => {
|
|
237
|
-
const flattened = {
|
|
238
|
-
teamId: '87654321-4321-4321-4321-210987654321',
|
|
239
|
-
teamName: 'Team Epsilon',
|
|
240
|
-
personId: '12345678-1234-4234-1234-123456789012'
|
|
241
|
-
};
|
|
242
|
-
const teamProperties = User_1.User.TeamProperties.builder.build(flattened);
|
|
243
|
-
(0, core_1.expect)(teamProperties.teamId.value.guidString).toBeEqual('87654321-4321-4321-4321-210987654321');
|
|
244
|
-
(0, core_1.expect)(teamProperties.teamName).toBeEqual('Team Epsilon');
|
|
245
|
-
(0, core_1.expect)(teamProperties.personId.value.guidString).toBeEqual('12345678-1234-4234-1234-123456789012');
|
|
246
|
-
});
|
|
247
|
-
it('should round-trip through flatten and build', () => {
|
|
248
|
-
const teamId = Team_1.Team.Id.builder.build('12345678-1234-4234-1234-123456789012');
|
|
249
|
-
const personId = Person_1.Person.Id.builder.build('87654321-4321-4321-4321-210987654321');
|
|
250
|
-
const original = new User_1.User.TeamProperties(teamId, 'Team Zeta', personId);
|
|
251
|
-
const rebuilt = User_1.User.TeamProperties.builder.build(original.flatten);
|
|
252
|
-
(0, core_1.expect)(rebuilt.teamId.flatten).toBeEqual(original.teamId.flatten);
|
|
253
|
-
(0, core_1.expect)(rebuilt.teamName).toBeEqual(original.teamName);
|
|
254
|
-
(0, core_1.expect)(rebuilt.personId.flatten).toBeEqual(original.personId.flatten);
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
describe('User', () => {
|
|
259
|
-
describe('User constructor', () => {
|
|
260
|
-
it('should create a user with ID and empty teams dictionary', () => {
|
|
261
|
-
const userId = User_1.User.Id.builder.build('user-001');
|
|
262
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
263
|
-
const signInType = new User_1.User.SignInTypeEmail('user001@test.com');
|
|
264
|
-
const user = new User_1.User(userId, signInDate, signInType);
|
|
265
|
-
(0, core_1.expect)(user.id).toBeEqual(userId);
|
|
266
|
-
(0, core_1.expect)(user.signInDate).toBeEqual(signInDate);
|
|
267
|
-
(0, core_1.expect)(user.signInType).toBeEqual(signInType);
|
|
268
|
-
(0, core_1.expect)(user.teams.values.length).toBeEqual(0);
|
|
269
|
-
});
|
|
270
|
-
it('should create a user with ID and teams', () => {
|
|
271
|
-
const userId = User_1.User.Id.builder.build('user-002');
|
|
272
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
273
|
-
const signInType = new User_1.User.SignInTypeOAuth('google');
|
|
274
|
-
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
275
|
-
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
276
|
-
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team A', personId);
|
|
277
|
-
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
278
|
-
teams.set(teamId, teamProperties);
|
|
279
|
-
const user = new User_1.User(userId, signInDate, signInType, teams);
|
|
280
|
-
(0, core_1.expect)(user.id).toBeEqual(userId);
|
|
281
|
-
(0, core_1.expect)(user.signInDate).toBeEqual(signInDate);
|
|
282
|
-
(0, core_1.expect)(user.signInType).toBeEqual(signInType);
|
|
283
|
-
(0, core_1.expect)(user.teams.values.length).toBeEqual(1);
|
|
284
|
-
(0, core_1.expect)(user.teams.get(teamId)?.teamName).toBeEqual('Team A');
|
|
285
|
-
});
|
|
286
|
-
it('should create a user with multiple teams', () => {
|
|
287
|
-
const userId = User_1.User.Id.builder.build('user-003');
|
|
288
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
289
|
-
const signInType = new User_1.User.SignInTypeOAuth('apple');
|
|
290
|
-
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
291
|
-
const teamId1 = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
292
|
-
const personId1 = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
293
|
-
teams.set(teamId1, new User_1.User.TeamProperties(teamId1, 'Team One', personId1));
|
|
294
|
-
const teamId2 = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
295
|
-
const personId2 = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
296
|
-
teams.set(teamId2, new User_1.User.TeamProperties(teamId2, 'Team Two', personId2));
|
|
297
|
-
const user = new User_1.User(userId, signInDate, signInType, teams);
|
|
298
|
-
(0, core_1.expect)(user.teams.values.length).toBeEqual(2);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
describe('User.flatten', () => {
|
|
302
|
-
it('should return flattened representation with empty teams', () => {
|
|
303
|
-
const userId = User_1.User.Id.builder.build('user-flat-001');
|
|
304
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
305
|
-
const signInType = new User_1.User.SignInTypeEmail('flat001@test.com');
|
|
306
|
-
const user = new User_1.User(userId, signInDate, signInType);
|
|
307
|
-
const flattened = user.flatten;
|
|
308
|
-
(0, core_1.expect)(flattened.id).toBeEqual('user-flat-001');
|
|
309
|
-
(0, core_1.expect)(flattened.signInDate).toBeEqual(signInDate.flatten);
|
|
310
|
-
(0, core_1.expect)(flattened.signInType.type).toBeEqual('email');
|
|
311
|
-
(0, core_1.expect)(Object.keys(flattened.teams)).toBeEqual([]);
|
|
312
|
-
});
|
|
313
|
-
it('should return flattened representation with teams', () => {
|
|
314
|
-
const userId = User_1.User.Id.builder.build('user-flat-002');
|
|
315
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
316
|
-
const signInType = new User_1.User.SignInTypeOAuth('google');
|
|
317
|
-
const teamId = Team_1.Team.Id.builder.build('11111111-1111-4111-1111-111111111111');
|
|
318
|
-
const personId = Person_1.Person.Id.builder.build('22222222-2222-4222-2222-222222222222');
|
|
319
|
-
const teamProperties = new User_1.User.TeamProperties(teamId, 'Team Flatten', personId);
|
|
320
|
-
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
321
|
-
teams.set(teamId, teamProperties);
|
|
322
|
-
const user = new User_1.User(userId, signInDate, signInType, teams);
|
|
323
|
-
const flattened = user.flatten;
|
|
324
|
-
(0, core_1.expect)(flattened.id).toBeEqual('user-flat-002');
|
|
325
|
-
(0, core_1.expect)(flattened.signInDate).toBeEqual(signInDate.flatten);
|
|
326
|
-
(0, core_1.expect)(flattened.signInType.type).toBeEqual('google');
|
|
327
|
-
(0, core_1.expect)(flattened.teams['11111111-1111-4111-1111-111111111111']).not.toBeUndefined();
|
|
328
|
-
(0, core_1.expect)(flattened.teams['11111111-1111-4111-1111-111111111111'].teamName).toBeEqual('Team Flatten');
|
|
329
|
-
});
|
|
330
|
-
it('should match the original values', () => {
|
|
331
|
-
const userId = User_1.User.Id.builder.build('user-match-001');
|
|
332
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
333
|
-
const signInType = new User_1.User.SignInTypeEmail('match@test.com');
|
|
334
|
-
const teamId = Team_1.Team.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
335
|
-
const personId = Person_1.Person.Id.builder.build(typescript_common_functionality_1.Guid.generate().guidString);
|
|
336
|
-
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
337
|
-
teams.set(teamId, new User_1.User.TeamProperties(teamId, 'Match Team', personId));
|
|
338
|
-
const user = new User_1.User(userId, signInDate, signInType, teams);
|
|
339
|
-
const flattened = user.flatten;
|
|
340
|
-
(0, core_1.expect)(flattened.id).toBeEqual(userId.flatten);
|
|
341
|
-
(0, core_1.expect)(flattened.signInDate).toBeEqual(signInDate.flatten);
|
|
342
|
-
(0, core_1.expect)(flattened.signInType).toBeEqual(signInType.flatten);
|
|
343
|
-
});
|
|
344
|
-
it('should have correct structure', () => {
|
|
345
|
-
const userId = User_1.User.Id.builder.build('user-struct-001');
|
|
346
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
347
|
-
const signInType = new User_1.User.SignInTypeOAuth('apple');
|
|
348
|
-
const user = new User_1.User(userId, signInDate, signInType);
|
|
349
|
-
const flattened = user.flatten;
|
|
350
|
-
(0, core_1.expect)(typeof flattened.id).toBeEqual('string');
|
|
351
|
-
(0, core_1.expect)(typeof flattened.signInDate).toBeEqual('string');
|
|
352
|
-
(0, core_1.expect)(typeof flattened.signInType).toBeEqual('object');
|
|
353
|
-
(0, core_1.expect)(typeof flattened.teams).toBeEqual('object');
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
describe('User.TypeBuilder', () => {
|
|
357
|
-
it('should build user from flattened data with empty teams', () => {
|
|
358
|
-
const flattened = {
|
|
359
|
-
id: 'user-build-001',
|
|
360
|
-
signInDate: '2024-01-15-10-30',
|
|
361
|
-
signInType: {
|
|
362
|
-
type: 'email',
|
|
363
|
-
email: 'build001@test.com'
|
|
364
|
-
},
|
|
365
|
-
teams: {}
|
|
366
|
-
};
|
|
367
|
-
const user = User_1.User.builder.build(flattened);
|
|
368
|
-
(0, core_1.expect)(user.id.flatten).toBeEqual('user-build-001');
|
|
369
|
-
(0, core_1.expect)(user.signInDate.flatten).toBeEqual('2024-01-15-10-30');
|
|
370
|
-
(0, core_1.expect)(user.signInType instanceof User_1.User.SignInTypeEmail).toBeTrue();
|
|
371
|
-
(0, core_1.expect)(user.teams.values.length).toBeEqual(0);
|
|
372
|
-
});
|
|
373
|
-
it('should build user from flattened data with teams', () => {
|
|
374
|
-
const flattened = {
|
|
375
|
-
id: 'user-build-002',
|
|
376
|
-
signInDate: '2024-02-20-14-45',
|
|
377
|
-
signInType: {
|
|
378
|
-
type: 'google'
|
|
379
|
-
},
|
|
380
|
-
teams: {
|
|
381
|
-
'33333333-3333-4333-3333-333333333333': {
|
|
382
|
-
teamId: '33333333-3333-4333-3333-333333333333',
|
|
383
|
-
teamName: 'Built Team',
|
|
384
|
-
personId: '44444444-4444-4444-4444-444444444444'
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
const user = User_1.User.builder.build(flattened);
|
|
389
|
-
(0, core_1.expect)(user.id.flatten).toBeEqual('user-build-002');
|
|
390
|
-
(0, core_1.expect)(user.signInDate.flatten).toBeEqual('2024-02-20-14-45');
|
|
391
|
-
(0, core_1.expect)(user.signInType instanceof User_1.User.SignInTypeOAuth).toBeTrue();
|
|
392
|
-
(0, core_1.expect)(user.teams.values.length).toBeEqual(1);
|
|
393
|
-
const teamId = Team_1.Team.Id.builder.build('33333333-3333-4333-3333-333333333333');
|
|
394
|
-
(0, core_1.expect)(user.teams.get(teamId)?.teamName).toBeEqual('Built Team');
|
|
395
|
-
});
|
|
396
|
-
it('should round-trip through flatten and build with empty teams', () => {
|
|
397
|
-
const userId = User_1.User.Id.builder.build('user-round-001');
|
|
398
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
399
|
-
const signInType = new User_1.User.SignInTypeEmail('round001@test.com');
|
|
400
|
-
const original = new User_1.User(userId, signInDate, signInType);
|
|
401
|
-
const rebuilt = User_1.User.builder.build(original.flatten);
|
|
402
|
-
(0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
|
|
403
|
-
(0, core_1.expect)(rebuilt.signInDate.flatten).toBeEqual(original.signInDate.flatten);
|
|
404
|
-
(0, core_1.expect)(rebuilt.signInType.flatten).toBeEqual(original.signInType.flatten);
|
|
405
|
-
(0, core_1.expect)(rebuilt.teams.values.length).toBeEqual(original.teams.values.length);
|
|
406
|
-
});
|
|
407
|
-
it('should round-trip through flatten and build with teams', () => {
|
|
408
|
-
const userId = User_1.User.Id.builder.build('user-round-002');
|
|
409
|
-
const signInDate = typescript_common_functionality_1.UtcDate.now;
|
|
410
|
-
const signInType = new User_1.User.SignInTypeOAuth('apple');
|
|
411
|
-
const teamId = Team_1.Team.Id.builder.build('55555555-5555-4555-5555-555555555555');
|
|
412
|
-
const personId = Person_1.Person.Id.builder.build('66666666-6666-4666-6666-666666666666');
|
|
413
|
-
const teams = new typescript_common_functionality_1.Dictionary(Team_1.Team.Id.builder);
|
|
414
|
-
teams.set(teamId, new User_1.User.TeamProperties(teamId, 'Round Trip Team', personId));
|
|
415
|
-
const original = new User_1.User(userId, signInDate, signInType, teams);
|
|
416
|
-
const rebuilt = User_1.User.builder.build(original.flatten);
|
|
417
|
-
(0, core_1.expect)(rebuilt.id.flatten).toBeEqual(original.id.flatten);
|
|
418
|
-
(0, core_1.expect)(rebuilt.signInDate.flatten).toBeEqual(original.signInDate.flatten);
|
|
419
|
-
(0, core_1.expect)(rebuilt.signInType.flatten).toBeEqual(original.signInType.flatten);
|
|
420
|
-
(0, core_1.expect)(rebuilt.teams.values.length).toBeEqual(original.teams.values.length);
|
|
421
|
-
(0, core_1.expect)(rebuilt.teams.get(teamId)?.teamName).toBeEqual('Round Trip Team');
|
|
422
|
-
(0, core_1.expect)(rebuilt.teams.get(teamId)?.personId.flatten).toBeEqual(personId.flatten);
|
|
423
|
-
});
|
|
424
|
-
it('should build user with multiple teams', () => {
|
|
425
|
-
const flattened = {
|
|
426
|
-
id: 'user-multi-001',
|
|
427
|
-
signInDate: '2024-03-25T16:00:00.000Z',
|
|
428
|
-
signInType: {
|
|
429
|
-
type: 'email',
|
|
430
|
-
email: 'multi@test.com'
|
|
431
|
-
},
|
|
432
|
-
teams: {
|
|
433
|
-
'77777777-7777-4777-7777-777777777777': {
|
|
434
|
-
teamId: '77777777-7777-4777-7777-777777777777',
|
|
435
|
-
teamName: 'Multi Team 1',
|
|
436
|
-
personId: '88888888-8888-4888-8888-888888888888'
|
|
437
|
-
},
|
|
438
|
-
'99999999-9999-4999-9999-999999999999': {
|
|
439
|
-
teamId: '99999999-9999-4999-9999-999999999999',
|
|
440
|
-
teamName: 'Multi Team 2',
|
|
441
|
-
personId: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaaaa'
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
const user = User_1.User.builder.build(flattened);
|
|
446
|
-
(0, core_1.expect)(user.teams.values.length).toBeEqual(2);
|
|
447
|
-
});
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const core_1 = require("@assertive-ts/core");
|
|
4
|
-
const UserRole_1 = require("../../src/types/UserRole");
|
|
5
|
-
const Locale_1 = require("../../src/types/Locale");
|
|
6
|
-
describe('UserRole', () => {
|
|
7
|
-
describe('UserRole type', () => {
|
|
8
|
-
it('should be valid user role types', () => {
|
|
9
|
-
const role1 = 'person-manager';
|
|
10
|
-
const role2 = 'fineTemplate-manager';
|
|
11
|
-
const role3 = 'fine-manager';
|
|
12
|
-
const role4 = 'fine-can-add';
|
|
13
|
-
const role5 = 'team-manager';
|
|
14
|
-
(0, core_1.expect)(role1).toBeEqual('person-manager');
|
|
15
|
-
(0, core_1.expect)(role2).toBeEqual('fineTemplate-manager');
|
|
16
|
-
(0, core_1.expect)(role3).toBeEqual('fine-manager');
|
|
17
|
-
(0, core_1.expect)(role4).toBeEqual('fine-can-add');
|
|
18
|
-
(0, core_1.expect)(role5).toBeEqual('team-manager');
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
describe('UserRole.all', () => {
|
|
22
|
-
it('should contain all user roles', () => {
|
|
23
|
-
(0, core_1.expect)(UserRole_1.UserRole.all).toBeEqual([
|
|
24
|
-
'person-manager',
|
|
25
|
-
'fineTemplate-manager',
|
|
26
|
-
'fine-manager',
|
|
27
|
-
'fine-can-add',
|
|
28
|
-
'team-manager'
|
|
29
|
-
]);
|
|
30
|
-
});
|
|
31
|
-
it('should have exactly 5 roles', () => {
|
|
32
|
-
(0, core_1.expect)(UserRole_1.UserRole.all.length).toBeEqual(5);
|
|
33
|
-
});
|
|
34
|
-
it('should contain person-manager', () => {
|
|
35
|
-
(0, core_1.expect)(UserRole_1.UserRole.all.includes('person-manager')).toBeTrue();
|
|
36
|
-
});
|
|
37
|
-
it('should contain fineTemplate-manager', () => {
|
|
38
|
-
(0, core_1.expect)(UserRole_1.UserRole.all.includes('fineTemplate-manager')).toBeTrue();
|
|
39
|
-
});
|
|
40
|
-
it('should contain fine-manager', () => {
|
|
41
|
-
(0, core_1.expect)(UserRole_1.UserRole.all.includes('fine-manager')).toBeTrue();
|
|
42
|
-
});
|
|
43
|
-
it('should contain fine-can-add', () => {
|
|
44
|
-
(0, core_1.expect)(UserRole_1.UserRole.all.includes('fine-can-add')).toBeTrue();
|
|
45
|
-
});
|
|
46
|
-
it('should contain team-manager', () => {
|
|
47
|
-
(0, core_1.expect)(UserRole_1.UserRole.all.includes('team-manager')).toBeTrue();
|
|
48
|
-
});
|
|
49
|
-
it('should contain only valid string types', () => {
|
|
50
|
-
for (const role of UserRole_1.UserRole.all) {
|
|
51
|
-
(0, core_1.expect)(typeof role).toBeEqual('string');
|
|
52
|
-
(0, core_1.expect)(role.length).toBeGreaterThan(0);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
describe('UserRole.formatted', () => {
|
|
57
|
-
describe('formatted with en locale', () => {
|
|
58
|
-
it('should format person-manager', () => {
|
|
59
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('person-manager', 'en')).toBeEqual('Person Manager');
|
|
60
|
-
});
|
|
61
|
-
it('should format fineTemplate-manager', () => {
|
|
62
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('fineTemplate-manager', 'en')).toBeEqual('Fine Template Manager');
|
|
63
|
-
});
|
|
64
|
-
it('should format fine-manager', () => {
|
|
65
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('fine-manager', 'en')).toBeEqual('Fine Manager');
|
|
66
|
-
});
|
|
67
|
-
it('should format fine-can-add', () => {
|
|
68
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('fine-can-add', 'en')).toBeEqual('Can add fines');
|
|
69
|
-
});
|
|
70
|
-
it('should format team-manager', () => {
|
|
71
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('team-manager', 'en')).toBeEqual('Team Manager');
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
describe('formatted with de locale', () => {
|
|
75
|
-
it('should format person-manager', () => {
|
|
76
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('person-manager', 'de')).toBeEqual('Personenmanager');
|
|
77
|
-
});
|
|
78
|
-
it('should format fineTemplate-manager', () => {
|
|
79
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('fineTemplate-manager', 'de')).toBeEqual('Strafvorlagenmanager');
|
|
80
|
-
});
|
|
81
|
-
it('should format fine-manager', () => {
|
|
82
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('fine-manager', 'de')).toBeEqual('Strafenmanager');
|
|
83
|
-
});
|
|
84
|
-
it('should format fine-can-add', () => {
|
|
85
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('fine-can-add', 'de')).toBeEqual('Kann Strafen hinzufügen');
|
|
86
|
-
});
|
|
87
|
-
it('should format team-manager', () => {
|
|
88
|
-
(0, core_1.expect)(UserRole_1.UserRole.formatted('team-manager', 'de')).toBeEqual('Teammanager');
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe('formatted for all roles and locales', () => {
|
|
92
|
-
it('should format all roles in all locales', () => {
|
|
93
|
-
for (const role of UserRole_1.UserRole.all) {
|
|
94
|
-
for (const locale of Locale_1.Locale.all) {
|
|
95
|
-
const formatted = UserRole_1.UserRole.formatted(role, locale);
|
|
96
|
-
(0, core_1.expect)(typeof formatted).toBeEqual('string');
|
|
97
|
-
(0, core_1.expect)(formatted.length).toBeGreaterThan(0);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
it('should return different values for different locales', () => {
|
|
102
|
-
for (const role of UserRole_1.UserRole.all) {
|
|
103
|
-
const formattedEN = UserRole_1.UserRole.formatted(role, 'en');
|
|
104
|
-
const formattedDE = UserRole_1.UserRole.formatted(role, 'de');
|
|
105
|
-
// Most roles should have different translations
|
|
106
|
-
// (though some might be similar, so we just check they're strings)
|
|
107
|
-
(0, core_1.expect)(typeof formattedEN).toBeEqual('string');
|
|
108
|
-
(0, core_1.expect)(typeof formattedDE).toBeEqual('string');
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
describe('UserRole.builder', () => {
|
|
114
|
-
it('should build valid user role from string', () => {
|
|
115
|
-
const role1 = UserRole_1.UserRole.builder.build('person-manager');
|
|
116
|
-
const role2 = UserRole_1.UserRole.builder.build('team-manager');
|
|
117
|
-
(0, core_1.expect)(role1).toBeEqual('person-manager');
|
|
118
|
-
(0, core_1.expect)(role2).toBeEqual('team-manager');
|
|
119
|
-
});
|
|
120
|
-
it('should preserve user role value', () => {
|
|
121
|
-
for (const role of UserRole_1.UserRole.all) {
|
|
122
|
-
const built = UserRole_1.UserRole.builder.build(role);
|
|
123
|
-
(0, core_1.expect)(built).toBeEqual(role);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
it('should build all user roles', () => {
|
|
127
|
-
const roles = [
|
|
128
|
-
'person-manager',
|
|
129
|
-
'fineTemplate-manager',
|
|
130
|
-
'fine-manager',
|
|
131
|
-
'fine-can-add',
|
|
132
|
-
'team-manager'
|
|
133
|
-
];
|
|
134
|
-
for (const role of roles) {
|
|
135
|
-
const built = UserRole_1.UserRole.builder.build(role);
|
|
136
|
-
(0, core_1.expect)(built).toBeEqual(role);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|