@stevenkellner/team-conduct-api 1.0.35 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +41 -42
- package/lib/src/functions/invitation/getInvitation.js +58 -81
- 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 +83 -109
- 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,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const Invitation_1 = require("../../src/types/Invitation");
|
|
5
|
+
const Team_1 = require("../../src/types/Team");
|
|
6
|
+
const Person_1 = require("../../src/types/Person");
|
|
7
|
+
describe('Invitation', () => {
|
|
8
|
+
describe('Invitation.Id', () => {
|
|
9
|
+
describe('Invitation.Id type', () => {
|
|
10
|
+
it('should create a valid invitation ID', () => {
|
|
11
|
+
const invitationId = Invitation_1.Invitation.Id.builder.build('a1b2c3d4e5f6');
|
|
12
|
+
(0, core_1.expect)(invitationId.value).toBeEqual('a1b2c3d4e5f6');
|
|
13
|
+
});
|
|
14
|
+
it('should have 12 character hex string', () => {
|
|
15
|
+
const invitationId = Invitation_1.Invitation.Id.builder.build('123456789abc');
|
|
16
|
+
(0, core_1.expect)(invitationId.value.length).toBeEqual(12);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
describe('Invitation.Id.builder', () => {
|
|
20
|
+
it('should build invitation ID from string', () => {
|
|
21
|
+
const idString = 'a1b2c3d4e5f6';
|
|
22
|
+
const invitationId = Invitation_1.Invitation.Id.builder.build(idString);
|
|
23
|
+
(0, core_1.expect)(invitationId.flatten).toBeEqual(idString);
|
|
24
|
+
});
|
|
25
|
+
it('should preserve invitation ID value', () => {
|
|
26
|
+
const idString = '123456789abc';
|
|
27
|
+
const invitationId = Invitation_1.Invitation.Id.builder.build(idString);
|
|
28
|
+
(0, core_1.expect)(invitationId.flatten).toBeEqual(idString);
|
|
29
|
+
});
|
|
30
|
+
it('should build different invitation IDs', () => {
|
|
31
|
+
const id1 = Invitation_1.Invitation.Id.builder.build('aaa111bbb222');
|
|
32
|
+
const id2 = Invitation_1.Invitation.Id.builder.build('ccc333ddd444');
|
|
33
|
+
(0, core_1.expect)(id1.flatten).not.toBeEqual(id2.flatten);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe('Invitation', () => {
|
|
38
|
+
describe('Invitation constructor', () => {
|
|
39
|
+
it('should create invitation with team ID and null person ID', () => {
|
|
40
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
41
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
42
|
+
(0, core_1.expect)(invitation.teamId).toBeEqual(teamId);
|
|
43
|
+
(0, core_1.expect)(invitation.personId).toBeEqual(null);
|
|
44
|
+
});
|
|
45
|
+
it('should create invitation with team ID and person ID', () => {
|
|
46
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
47
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
48
|
+
const invitation = new Invitation_1.Invitation(teamId, personId);
|
|
49
|
+
(0, core_1.expect)(invitation.teamId).toBeEqual(teamId);
|
|
50
|
+
(0, core_1.expect)(invitation.personId).toBeEqual(personId);
|
|
51
|
+
});
|
|
52
|
+
it('should create team-wide invitation', () => {
|
|
53
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
54
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
55
|
+
(0, core_1.expect)(invitation.personId).toBeEqual(null);
|
|
56
|
+
});
|
|
57
|
+
it('should create person-specific invitation', () => {
|
|
58
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
59
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
60
|
+
const invitation = new Invitation_1.Invitation(teamId, personId);
|
|
61
|
+
(0, core_1.expect)(invitation.personId).not.toBeEqual(null);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
describe('Invitation.createId', () => {
|
|
65
|
+
it('should create invitation ID from team-wide invitation', () => {
|
|
66
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
67
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
68
|
+
const invitationId = invitation.createId();
|
|
69
|
+
(0, core_1.expect)(invitationId.flatten.length).toBeEqual(12);
|
|
70
|
+
});
|
|
71
|
+
it('should create invitation ID from person-specific invitation', () => {
|
|
72
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
73
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
74
|
+
const invitation = new Invitation_1.Invitation(teamId, personId);
|
|
75
|
+
const invitationId = invitation.createId();
|
|
76
|
+
(0, core_1.expect)(invitationId.flatten.length).toBeEqual(12);
|
|
77
|
+
});
|
|
78
|
+
it('should create consistent IDs for same team-wide invitation', () => {
|
|
79
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
80
|
+
const invitation1 = new Invitation_1.Invitation(teamId, null);
|
|
81
|
+
const invitation2 = new Invitation_1.Invitation(teamId, null);
|
|
82
|
+
const id1 = invitation1.createId();
|
|
83
|
+
const id2 = invitation2.createId();
|
|
84
|
+
(0, core_1.expect)(id1.flatten).toBeEqual(id2.flatten);
|
|
85
|
+
});
|
|
86
|
+
it('should create consistent IDs for same person-specific invitation', () => {
|
|
87
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
88
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
89
|
+
const invitation1 = new Invitation_1.Invitation(teamId, personId);
|
|
90
|
+
const invitation2 = new Invitation_1.Invitation(teamId, personId);
|
|
91
|
+
const id1 = invitation1.createId();
|
|
92
|
+
const id2 = invitation2.createId();
|
|
93
|
+
(0, core_1.expect)(id1.flatten).toBeEqual(id2.flatten);
|
|
94
|
+
});
|
|
95
|
+
it('should create different IDs for different teams', () => {
|
|
96
|
+
const teamId1 = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
97
|
+
const teamId2 = Team_1.Team.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
98
|
+
const invitation1 = new Invitation_1.Invitation(teamId1, null);
|
|
99
|
+
const invitation2 = new Invitation_1.Invitation(teamId2, null);
|
|
100
|
+
const id1 = invitation1.createId();
|
|
101
|
+
const id2 = invitation2.createId();
|
|
102
|
+
(0, core_1.expect)(id1.flatten).not.toBeEqual(id2.flatten);
|
|
103
|
+
});
|
|
104
|
+
it('should create different IDs for different persons', () => {
|
|
105
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
106
|
+
const personId1 = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
107
|
+
const personId2 = Person_1.Person.Id.builder.build('c3333333-3333-4333-3333-333333333333');
|
|
108
|
+
const invitation1 = new Invitation_1.Invitation(teamId, personId1);
|
|
109
|
+
const invitation2 = new Invitation_1.Invitation(teamId, personId2);
|
|
110
|
+
const id1 = invitation1.createId();
|
|
111
|
+
const id2 = invitation2.createId();
|
|
112
|
+
(0, core_1.expect)(id1.flatten).not.toBeEqual(id2.flatten);
|
|
113
|
+
});
|
|
114
|
+
it('should create different IDs for team-wide vs person-specific', () => {
|
|
115
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
116
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
117
|
+
const invitation1 = new Invitation_1.Invitation(teamId, null);
|
|
118
|
+
const invitation2 = new Invitation_1.Invitation(teamId, personId);
|
|
119
|
+
const id1 = invitation1.createId();
|
|
120
|
+
const id2 = invitation2.createId();
|
|
121
|
+
(0, core_1.expect)(id1.flatten).not.toBeEqual(id2.flatten);
|
|
122
|
+
});
|
|
123
|
+
it('should create hex string IDs', () => {
|
|
124
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
125
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
126
|
+
const invitationId = invitation.createId();
|
|
127
|
+
const hexPattern = /^[0-9a-f]{12}$/;
|
|
128
|
+
(0, core_1.expect)(hexPattern.test(invitationId.flatten)).toBeTrue();
|
|
129
|
+
});
|
|
130
|
+
it('should create IDs with exactly 12 characters', () => {
|
|
131
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
132
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
133
|
+
const invitation = new Invitation_1.Invitation(teamId, personId);
|
|
134
|
+
const invitationId = invitation.createId();
|
|
135
|
+
(0, core_1.expect)(invitationId.flatten.length).toBeEqual(12);
|
|
136
|
+
});
|
|
137
|
+
it('should create tagged invitation ID', () => {
|
|
138
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
139
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
140
|
+
const invitationId = invitation.createId();
|
|
141
|
+
(0, core_1.expect)(invitationId.tag).toBeEqual('invitation');
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
describe('Invitation.flatten', () => {
|
|
145
|
+
it('should return flattened representation with null person ID', () => {
|
|
146
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
147
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
148
|
+
const flattened = invitation.flatten;
|
|
149
|
+
(0, core_1.expect)(flattened.teamId).toBeEqual(teamId.flatten);
|
|
150
|
+
(0, core_1.expect)(flattened.personId).toBeEqual(null);
|
|
151
|
+
});
|
|
152
|
+
it('should return flattened representation with person ID', () => {
|
|
153
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
154
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
155
|
+
const invitation = new Invitation_1.Invitation(teamId, personId);
|
|
156
|
+
const flattened = invitation.flatten;
|
|
157
|
+
(0, core_1.expect)(flattened.teamId).toBeEqual(teamId.flatten);
|
|
158
|
+
(0, core_1.expect)(flattened.personId).toBeEqual(personId.flatten);
|
|
159
|
+
});
|
|
160
|
+
it('should match original values', () => {
|
|
161
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
162
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
163
|
+
const invitation = new Invitation_1.Invitation(teamId, personId);
|
|
164
|
+
const flattened = invitation.flatten;
|
|
165
|
+
(0, core_1.expect)(flattened.teamId).toBeEqual(invitation.teamId.flatten);
|
|
166
|
+
(0, core_1.expect)(flattened.personId).toBeEqual(invitation.personId?.flatten ?? null);
|
|
167
|
+
});
|
|
168
|
+
it('should have correct structure', () => {
|
|
169
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
170
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
171
|
+
const flattened = invitation.flatten;
|
|
172
|
+
(0, core_1.expect)(typeof flattened.teamId).toBeEqual('string');
|
|
173
|
+
(0, core_1.expect)(flattened.personId === null || typeof flattened.personId === 'string').toBeTrue();
|
|
174
|
+
});
|
|
175
|
+
it('should flatten team-wide invitation correctly', () => {
|
|
176
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
177
|
+
const invitation = new Invitation_1.Invitation(teamId, null);
|
|
178
|
+
const flattened = invitation.flatten;
|
|
179
|
+
(0, core_1.expect)(flattened.personId).toBeEqual(null);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
describe('Invitation.TypeBuilder', () => {
|
|
183
|
+
it('should build invitation from flattened data with null person ID', () => {
|
|
184
|
+
const flattened = {
|
|
185
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
186
|
+
personId: null
|
|
187
|
+
};
|
|
188
|
+
const invitation = Invitation_1.Invitation.builder.build(flattened);
|
|
189
|
+
(0, core_1.expect)(invitation.teamId.flatten).toBeEqual(flattened.teamId);
|
|
190
|
+
(0, core_1.expect)(invitation.personId).toBeEqual(null);
|
|
191
|
+
});
|
|
192
|
+
it('should build invitation from flattened data with person ID', () => {
|
|
193
|
+
const flattened = {
|
|
194
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
195
|
+
personId: 'b2222222-2222-4222-2222-222222222222'
|
|
196
|
+
};
|
|
197
|
+
const invitation = Invitation_1.Invitation.builder.build(flattened);
|
|
198
|
+
(0, core_1.expect)(invitation.teamId.flatten).toBeEqual(flattened.teamId);
|
|
199
|
+
(0, core_1.expect)(invitation.personId?.flatten).toBeEqual(flattened.personId);
|
|
200
|
+
});
|
|
201
|
+
it('should build team-wide invitation', () => {
|
|
202
|
+
const flattened = {
|
|
203
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
204
|
+
personId: null
|
|
205
|
+
};
|
|
206
|
+
const invitation = Invitation_1.Invitation.builder.build(flattened);
|
|
207
|
+
(0, core_1.expect)(invitation.personId).toBeEqual(null);
|
|
208
|
+
});
|
|
209
|
+
it('should build person-specific invitation', () => {
|
|
210
|
+
const flattened = {
|
|
211
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
212
|
+
personId: 'b2222222-2222-4222-2222-222222222222'
|
|
213
|
+
};
|
|
214
|
+
const invitation = Invitation_1.Invitation.builder.build(flattened);
|
|
215
|
+
(0, core_1.expect)(invitation.personId).not.toBeEqual(null);
|
|
216
|
+
});
|
|
217
|
+
it('should round-trip through flatten and build with null person ID', () => {
|
|
218
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
219
|
+
const original = new Invitation_1.Invitation(teamId, null);
|
|
220
|
+
const rebuilt = Invitation_1.Invitation.builder.build(original.flatten);
|
|
221
|
+
(0, core_1.expect)(rebuilt.teamId.flatten).toBeEqual(original.teamId.flatten);
|
|
222
|
+
(0, core_1.expect)(rebuilt.personId).toBeEqual(null);
|
|
223
|
+
});
|
|
224
|
+
it('should round-trip through flatten and build with person ID', () => {
|
|
225
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
226
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
227
|
+
const original = new Invitation_1.Invitation(teamId, personId);
|
|
228
|
+
const rebuilt = Invitation_1.Invitation.builder.build(original.flatten);
|
|
229
|
+
(0, core_1.expect)(rebuilt.teamId.flatten).toBeEqual(original.teamId.flatten);
|
|
230
|
+
(0, core_1.expect)(rebuilt.personId?.flatten).toBeEqual(original.personId?.flatten);
|
|
231
|
+
});
|
|
232
|
+
it('should preserve invitation ID consistency after round-trip', () => {
|
|
233
|
+
const teamId = Team_1.Team.Id.builder.build('a1111111-1111-4111-1111-111111111111');
|
|
234
|
+
const personId = Person_1.Person.Id.builder.build('b2222222-2222-4222-2222-222222222222');
|
|
235
|
+
const original = new Invitation_1.Invitation(teamId, personId);
|
|
236
|
+
const originalId = original.createId();
|
|
237
|
+
const rebuilt = Invitation_1.Invitation.builder.build(original.flatten);
|
|
238
|
+
const rebuiltId = rebuilt.createId();
|
|
239
|
+
(0, core_1.expect)(rebuiltId.flatten).toBeEqual(originalId.flatten);
|
|
240
|
+
});
|
|
241
|
+
it('should build with different team IDs', () => {
|
|
242
|
+
const flattened1 = {
|
|
243
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
244
|
+
personId: null
|
|
245
|
+
};
|
|
246
|
+
const flattened2 = {
|
|
247
|
+
teamId: 'b2222222-2222-4222-2222-222222222222',
|
|
248
|
+
personId: null
|
|
249
|
+
};
|
|
250
|
+
const invitation1 = Invitation_1.Invitation.builder.build(flattened1);
|
|
251
|
+
const invitation2 = Invitation_1.Invitation.builder.build(flattened2);
|
|
252
|
+
(0, core_1.expect)(invitation1.teamId.flatten).not.toBeEqual(invitation2.teamId.flatten);
|
|
253
|
+
});
|
|
254
|
+
it('should build with different person IDs', () => {
|
|
255
|
+
const flattened1 = {
|
|
256
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
257
|
+
personId: 'b2222222-2222-4222-2222-222222222222'
|
|
258
|
+
};
|
|
259
|
+
const flattened2 = {
|
|
260
|
+
teamId: 'a1111111-1111-4111-1111-111111111111',
|
|
261
|
+
personId: 'c3333333-3333-4333-3333-333333333333'
|
|
262
|
+
};
|
|
263
|
+
const invitation1 = Invitation_1.Invitation.builder.build(flattened1);
|
|
264
|
+
const invitation2 = Invitation_1.Invitation.builder.build(flattened2);
|
|
265
|
+
(0, core_1.expect)(invitation1.personId?.flatten).not.toBeEqual(invitation2.personId?.flatten);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const Locale_1 = require("../../src/types/Locale");
|
|
5
|
+
const Localization_1 = require("../../src/types/Localization");
|
|
6
|
+
const typescript_common_functionality_1 = require("@stevenkellner/typescript-common-functionality");
|
|
7
|
+
describe('Locale', () => {
|
|
8
|
+
describe('Locale type', () => {
|
|
9
|
+
it('should be a valid locale type', () => {
|
|
10
|
+
const locale1 = 'en';
|
|
11
|
+
const locale2 = 'de';
|
|
12
|
+
(0, core_1.expect)(locale1).toBeEqual('en');
|
|
13
|
+
(0, core_1.expect)(locale2).toBeEqual('de');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
describe('Locale.all', () => {
|
|
17
|
+
it('should contain all available locales', () => {
|
|
18
|
+
(0, core_1.expect)(Locale_1.Locale.all.length).toBeEqual(2);
|
|
19
|
+
(0, core_1.expect)(Locale_1.Locale.all).toContainAll('en', 'de');
|
|
20
|
+
});
|
|
21
|
+
it('should match keys from localizations', () => {
|
|
22
|
+
const localizationKeys = (0, typescript_common_functionality_1.keys)(Localization_1.localizations);
|
|
23
|
+
(0, core_1.expect)(Locale_1.Locale.all).toBeEqual(localizationKeys);
|
|
24
|
+
});
|
|
25
|
+
it('should contain only valid locale strings', () => {
|
|
26
|
+
for (const locale of Locale_1.Locale.all) {
|
|
27
|
+
(0, core_1.expect)(typeof locale).toBeEqual('string');
|
|
28
|
+
(0, core_1.expect)(locale.length).toBeGreaterThan(0);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('Locale.builder', () => {
|
|
33
|
+
it('should build valid locale from string', () => {
|
|
34
|
+
const locale1 = Locale_1.Locale.builder.build('en');
|
|
35
|
+
const locale2 = Locale_1.Locale.builder.build('de');
|
|
36
|
+
(0, core_1.expect)(locale1).toBeEqual('en');
|
|
37
|
+
(0, core_1.expect)(locale2).toBeEqual('de');
|
|
38
|
+
});
|
|
39
|
+
it('should preserve locale value', () => {
|
|
40
|
+
for (const locale of Locale_1.Locale.all) {
|
|
41
|
+
const built = Locale_1.Locale.builder.build(locale);
|
|
42
|
+
(0, core_1.expect)(built).toBeEqual(locale);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@assertive-ts/core");
|
|
4
|
+
const Localization_1 = require("../../src/types/Localization");
|
|
5
|
+
const Pluralization_1 = require("../../src/types/Pluralization");
|
|
6
|
+
describe('Localization', () => {
|
|
7
|
+
describe('localizations', () => {
|
|
8
|
+
it('should contain en and de locales', () => {
|
|
9
|
+
(0, core_1.expect)(Object.keys(Localization_1.localizations).sort()).toBeEqual(['de', 'en']);
|
|
10
|
+
});
|
|
11
|
+
it('should have en locale', () => {
|
|
12
|
+
(0, core_1.expect)(Localization_1.localizations.en).not.toBeUndefined();
|
|
13
|
+
});
|
|
14
|
+
it('should have de locale', () => {
|
|
15
|
+
(0, core_1.expect)(Localization_1.localizations.de).not.toBeUndefined();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
describe('Localization.shared', () => {
|
|
19
|
+
it('should return localization for en locale', () => {
|
|
20
|
+
const localization = Localization_1.Localization.shared('en');
|
|
21
|
+
(0, core_1.expect)(localization).not.toBeUndefined();
|
|
22
|
+
});
|
|
23
|
+
it('should return localization for de locale', () => {
|
|
24
|
+
const localization = Localization_1.Localization.shared('de');
|
|
25
|
+
(0, core_1.expect)(localization).not.toBeUndefined();
|
|
26
|
+
});
|
|
27
|
+
it('should return different instances for different locales', () => {
|
|
28
|
+
const localizationEN = Localization_1.Localization.shared('en');
|
|
29
|
+
const localizationDE = Localization_1.Localization.shared('de');
|
|
30
|
+
(0, core_1.expect)(localizationEN).not.toBe(localizationDE);
|
|
31
|
+
});
|
|
32
|
+
it('should access notification.fine.new.title', () => {
|
|
33
|
+
const localization = Localization_1.Localization.shared('en');
|
|
34
|
+
(0, core_1.expect)(localization.notification.fine.new.title).toBeInstanceOf(Localization_1.ValueLocalization);
|
|
35
|
+
});
|
|
36
|
+
it('should access nested localization values', () => {
|
|
37
|
+
const localization = Localization_1.Localization.shared('en');
|
|
38
|
+
(0, core_1.expect)(localization.payedState.payed).toBeInstanceOf(Localization_1.ValueLocalization);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('ValueLocalization', () => {
|
|
43
|
+
describe('ValueLocalization constructor', () => {
|
|
44
|
+
it('should create instance with simple string', () => {
|
|
45
|
+
const localization = new Localization_1.ValueLocalization('Hello World');
|
|
46
|
+
(0, core_1.expect)(localization.value()).toBeEqual('Hello World');
|
|
47
|
+
});
|
|
48
|
+
it('should create instance with template string', () => {
|
|
49
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}');
|
|
50
|
+
(0, core_1.expect)(localization.value({ name: 'World' })).toBeEqual('Hello World');
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe('ValueLocalization.value without variables', () => {
|
|
54
|
+
it('should return simple string without changes', () => {
|
|
55
|
+
const localization = new Localization_1.ValueLocalization('Simple text');
|
|
56
|
+
(0, core_1.expect)(localization.value()).toBeEqual('Simple text');
|
|
57
|
+
});
|
|
58
|
+
it('should return string with special characters', () => {
|
|
59
|
+
const localization = new Localization_1.ValueLocalization('Text with !@#$%^&*()');
|
|
60
|
+
(0, core_1.expect)(localization.value()).toBeEqual('Text with !@#$%^&*()');
|
|
61
|
+
});
|
|
62
|
+
it('should work with empty string', () => {
|
|
63
|
+
const localization = new Localization_1.ValueLocalization('');
|
|
64
|
+
(0, core_1.expect)(localization.value()).toBeEqual('');
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
describe('ValueLocalization.value with single variable', () => {
|
|
68
|
+
it('should replace single variable', () => {
|
|
69
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}');
|
|
70
|
+
(0, core_1.expect)(localization.value({ name: 'Alice' })).toBeEqual('Hello Alice');
|
|
71
|
+
});
|
|
72
|
+
it('should replace variable at start', () => {
|
|
73
|
+
const localization = new Localization_1.ValueLocalization('{{greeting}} World');
|
|
74
|
+
(0, core_1.expect)(localization.value({ greeting: 'Hello' })).toBeEqual('Hello World');
|
|
75
|
+
});
|
|
76
|
+
it('should replace variable at end', () => {
|
|
77
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}');
|
|
78
|
+
(0, core_1.expect)(localization.value({ name: 'Bob' })).toBeEqual('Hello Bob');
|
|
79
|
+
});
|
|
80
|
+
it('should replace variable in middle', () => {
|
|
81
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}, welcome!');
|
|
82
|
+
(0, core_1.expect)(localization.value({ name: 'Charlie' })).toBeEqual('Hello Charlie, welcome!');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
describe('ValueLocalization.value with multiple variables', () => {
|
|
86
|
+
it('should replace two variables', () => {
|
|
87
|
+
const localization = new Localization_1.ValueLocalization('{{greeting}} {{name}}');
|
|
88
|
+
(0, core_1.expect)(localization.value({ greeting: 'Hello', name: 'World' })).toBeEqual('Hello World');
|
|
89
|
+
});
|
|
90
|
+
it('should replace three variables', () => {
|
|
91
|
+
const localization = new Localization_1.ValueLocalization('{{a}} {{b}} {{c}}');
|
|
92
|
+
(0, core_1.expect)(localization.value({ a: 'One', b: 'Two', c: 'Three' })).toBeEqual('One Two Three');
|
|
93
|
+
});
|
|
94
|
+
it('should replace variables with text between', () => {
|
|
95
|
+
const localization = new Localization_1.ValueLocalization('User {{name}} has {{count}} items');
|
|
96
|
+
(0, core_1.expect)(localization.value({ name: 'Alice', count: '5' })).toBeEqual('User Alice has 5 items');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe('ValueLocalization.value with same variable multiple times', () => {
|
|
100
|
+
it('should replace same variable twice', () => {
|
|
101
|
+
const localization = new Localization_1.ValueLocalization('{{name}} said: Hello {{name}}');
|
|
102
|
+
(0, core_1.expect)(localization.value({ name: 'Bob' })).toBeEqual('Bob said: Hello Bob');
|
|
103
|
+
});
|
|
104
|
+
it('should replace same variable three times', () => {
|
|
105
|
+
const localization = new Localization_1.ValueLocalization('{{x}} + {{x}} = {{x}}');
|
|
106
|
+
(0, core_1.expect)(localization.value({ x: '2' })).toBeEqual('2 + 2 = 2');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
describe('ValueLocalization.value error handling', () => {
|
|
110
|
+
it('should throw error when variable is missing', () => {
|
|
111
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}');
|
|
112
|
+
(0, core_1.expect)(() => localization.value()).toThrow();
|
|
113
|
+
});
|
|
114
|
+
it('should throw error with message about missing key', () => {
|
|
115
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}');
|
|
116
|
+
try {
|
|
117
|
+
localization.value();
|
|
118
|
+
(0, core_1.expect)(false).toBeTrue(); // Should not reach here
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
(0, core_1.expect)(error.message).toContain('Missing argument for key: name');
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
it('should throw error when one of multiple variables is missing', () => {
|
|
125
|
+
const localization = new Localization_1.ValueLocalization('{{greeting}} {{name}}');
|
|
126
|
+
(0, core_1.expect)(() => localization.value({ greeting: 'Hello' })).toThrow();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
describe('ValueLocalization.value with extra arguments', () => {
|
|
130
|
+
it('should ignore extra arguments', () => {
|
|
131
|
+
const localization = new Localization_1.ValueLocalization('Hello {{name}}');
|
|
132
|
+
(0, core_1.expect)(localization.value({ name: 'World', extra: 'ignored' })).toBeEqual('Hello World');
|
|
133
|
+
});
|
|
134
|
+
it('should work with only extra arguments for no-variable string', () => {
|
|
135
|
+
const localization = new Localization_1.ValueLocalization('Hello World');
|
|
136
|
+
(0, core_1.expect)(localization.value({ extra: 'ignored' })).toBeEqual('Hello World');
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe('PluralLocalization', () => {
|
|
141
|
+
describe('PluralLocalization constructor', () => {
|
|
142
|
+
it('should create instance with Pluralization', () => {
|
|
143
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
144
|
+
one: 'one item',
|
|
145
|
+
other: '{{count}} items'
|
|
146
|
+
});
|
|
147
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
148
|
+
(0, core_1.expect)(localization.value(1)).toBeEqual('one item');
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
describe('PluralLocalization.value with count', () => {
|
|
152
|
+
it('should return singular form for count = 1', () => {
|
|
153
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
154
|
+
one: 'one item',
|
|
155
|
+
other: '{{count}} items'
|
|
156
|
+
});
|
|
157
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
158
|
+
(0, core_1.expect)(localization.value(1)).toBeEqual('one item');
|
|
159
|
+
});
|
|
160
|
+
it('should return plural form for count = 0', () => {
|
|
161
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
162
|
+
one: 'one item',
|
|
163
|
+
other: '{{count}} items'
|
|
164
|
+
});
|
|
165
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
166
|
+
(0, core_1.expect)(localization.value(0)).toBeEqual('0 items');
|
|
167
|
+
});
|
|
168
|
+
it('should return plural form for count = 5', () => {
|
|
169
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
170
|
+
one: 'one item',
|
|
171
|
+
other: '{{count}} items'
|
|
172
|
+
});
|
|
173
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
174
|
+
(0, core_1.expect)(localization.value(5)).toBeEqual('5 items');
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
describe('PluralLocalization.value with count variable', () => {
|
|
178
|
+
it('should automatically include count in template', () => {
|
|
179
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
180
|
+
other: 'Total: {{count}}'
|
|
181
|
+
});
|
|
182
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
183
|
+
(0, core_1.expect)(localization.value(42)).toBeEqual('Total: 42');
|
|
184
|
+
});
|
|
185
|
+
it('should use count in plural form', () => {
|
|
186
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
187
|
+
one: '{{count}} message',
|
|
188
|
+
other: '{{count}} messages'
|
|
189
|
+
});
|
|
190
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
191
|
+
(0, core_1.expect)(localization.value(1)).toBeEqual('1 message');
|
|
192
|
+
(0, core_1.expect)(localization.value(5)).toBeEqual('5 messages');
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
describe('PluralLocalization.value with additional arguments', () => {
|
|
196
|
+
it('should combine count with additional arguments', () => {
|
|
197
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
198
|
+
other: '{{name}} has {{count}} items'
|
|
199
|
+
});
|
|
200
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
201
|
+
(0, core_1.expect)(localization.value(5, { name: 'Alice' })).toBeEqual('Alice has 5 items');
|
|
202
|
+
});
|
|
203
|
+
it('should use all provided arguments', () => {
|
|
204
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
205
|
+
one: '{{user}} has {{count}} {{type}}',
|
|
206
|
+
other: '{{user}} has {{count}} {{type}}s'
|
|
207
|
+
});
|
|
208
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
209
|
+
(0, core_1.expect)(localization.value(1, { user: 'Bob', type: 'file' })).toBeEqual('Bob has 1 file');
|
|
210
|
+
(0, core_1.expect)(localization.value(3, { user: 'Bob', type: 'file' })).toBeEqual('Bob has 3 files');
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
describe('PluralLocalization.value with complex pluralization', () => {
|
|
214
|
+
it('should work with zero form', () => {
|
|
215
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
216
|
+
zero: 'no items',
|
|
217
|
+
one: 'one item',
|
|
218
|
+
other: '{{count}} items'
|
|
219
|
+
});
|
|
220
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
221
|
+
(0, core_1.expect)(localization.value(0)).toBeEqual('no items');
|
|
222
|
+
});
|
|
223
|
+
it('should work with all plural forms', () => {
|
|
224
|
+
const pluralization = new Pluralization_1.Pluralization({
|
|
225
|
+
zero: 'zero',
|
|
226
|
+
one: 'one',
|
|
227
|
+
two: 'two',
|
|
228
|
+
few: 'few ({{count}})',
|
|
229
|
+
many: 'many ({{count}})',
|
|
230
|
+
other: 'other ({{count}})'
|
|
231
|
+
});
|
|
232
|
+
const localization = new Localization_1.PluralLocalization(pluralization);
|
|
233
|
+
(0, core_1.expect)(localization.value(0)).toBeEqual('zero');
|
|
234
|
+
(0, core_1.expect)(localization.value(1)).toBeEqual('one');
|
|
235
|
+
(0, core_1.expect)(localization.value(2)).toBeEqual('two');
|
|
236
|
+
(0, core_1.expect)(localization.value(3)).toBeEqual('few (3)');
|
|
237
|
+
(0, core_1.expect)(localization.value(10)).toBeEqual('many (10)');
|
|
238
|
+
(0, core_1.expect)(localization.value(100)).toBeEqual('other (100)');
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|