Remove client-side isLoggedIn value
[ProtonMail-WebClient.git] / packages / shared / test / subscription / format.spec.ts
blobf26306128d5185ae79cdaee03668fb35ee7d70cc
1 import { PLANS } from '@proton/payments';
2 import type { Subscription } from '@proton/shared/lib/interfaces';
3 import format from '@proton/shared/lib/subscription/format';
5 describe('Subscription Format', () => {
6     let subscription: Subscription;
7     let upcoming: Subscription;
9     beforeEach(() => {
10         subscription = {
11             ID: 'k2ou1ckjSusQvcOkMvMYo5_9tO93iG-5l0ycRA2wxWXkgR_3uW086eI8xit5qENSOes9nPbjIvUjkn8FdpZPrw==',
12             InvoiceID: 'EodtkjoLzxaZpTfWOMEEsfqQuKftg11lPzfDuMxQFnX2sagjugYRm8AZ7O6N3K9mJdbLN_t0dbEMWuhs-EhSLQ==',
13             External: 0,
14             Cycle: 1,
15             PeriodStart: 1669038950,
16             PeriodEnd: 1671630950,
17             CreateTime: 1669038951,
18             CouponCode: null,
19             Currency: 'CHF',
20             Amount: 499,
21             Discount: 0,
22             RenewDiscount: 0,
23             RenewAmount: 499,
24             Plans: [
25                 {
26                     ID: 'Wb4NAqmiuqoA7kCHE28y92bBFfN8jaYQCLxHRAB96yGj-bh9SxguXC48_WSU-fRUjdAr-lx95c6rFLplgXyXYA==',
27                     Type: 1,
28                     Name: PLANS.MAIL,
29                     Title: 'Mail Plus',
30                     MaxDomains: 1,
31                     MaxAddresses: 10,
32                     MaxCalendars: 25,
33                     MaxSpace: 16106127360,
34                     MaxMembers: 1,
35                     MaxVPN: 0,
36                     MaxTier: 0,
37                     Services: 1,
38                     Features: 1,
39                     State: 1,
40                     Cycle: 1,
41                     Currency: 'CHF',
42                     Amount: 499,
43                     Quantity: 1,
44                     Offer: 'default',
45                 },
46             ],
47             Renew: 1,
48         };
50         upcoming = {
51             ID: 'klHlWI9EqPULc0sWO_C36DM8eHJ1H1bzIo4EmX-HG_VbDfS67gMvCt_5mhHFwHh9n02aNoux8qj4bUZOaebRUg==',
52             InvoiceID: 'EodtkjoLzxaZpTfWOMEEsfqQuKftg11lPzfDuMxQFnX2sagjugYRm8AZ7O6N3K9mJdbLN_t0dbEMWuhs-EhSLQ==',
53             Cycle: 12,
54             External: 0,
55             PeriodStart: 1671630950,
56             PeriodEnd: 1703166950,
57             CreateTime: 1669039317,
58             CouponCode: 'BUNDLE',
59             Currency: 'CHF',
60             Amount: 499,
61             Discount: 0,
62             RenewDiscount: 0,
63             RenewAmount: 4788,
64             Plans: [
65                 {
66                     ID: 'Wb4NAqmiuqoA7kCHE28y92bBFfN8jaYQCLxHRAB96yGj-bh9SxguXC48_WSU-fRUjdAr-lx95c6rFLplgXyXYA==',
67                     Type: 1,
68                     Name: PLANS.MAIL,
69                     Title: 'Mail Plus',
70                     MaxDomains: 1,
71                     MaxAddresses: 10,
72                     MaxCalendars: 25,
73                     MaxSpace: 16106127360,
74                     MaxMembers: 1,
75                     MaxVPN: 0,
76                     MaxTier: 0,
77                     Services: 1,
78                     Features: 1,
79                     State: 1,
80                     Cycle: 12,
81                     Currency: 'CHF',
82                     Amount: 4788,
83                     Quantity: 1,
84                     Offer: 'default',
85                 },
86             ],
87             Renew: 1,
88         };
89     });
91     it('should add isManagedByMozilla property', () => {
92         const result = format(subscription, undefined);
93         expect(result.isManagedByMozilla).toBeDefined();
94     });
96     it('should not add upcoming property if it is not specified', () => {
97         const result = format(subscription, undefined);
98         expect(result.UpcomingSubscription).not.toBeDefined();
99     });
101     it('should add upcoming property if it is the second parameter', () => {
102         const result = format(subscription, upcoming);
103         expect(result.UpcomingSubscription).toBeDefined();
104     });