richie-education 2.25.0-b2.dev62 → 2.25.0-b2.dev63

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.
@@ -27,9 +27,10 @@ describe('CreditCardHelper', () => {
27
27
  });
28
28
 
29
29
  it('is soon expired', () => {
30
- const expirationDate = faker.date.future({
31
- refDate: new Date(),
32
- years: 2.99 / 12,
30
+ const now = new Date();
31
+ const expirationDate = faker.date.between({
32
+ from: now,
33
+ to: new Date(now.getFullYear(), now.getMonth() + 4, 0, 23, 59, 59),
33
34
  });
34
35
 
35
36
  expect(
@@ -43,7 +44,10 @@ describe('CreditCardHelper', () => {
43
44
  });
44
45
 
45
46
  it('is expired', () => {
46
- const date = faker.date.past();
47
+ const now = new Date();
48
+ const date = faker.date.past({
49
+ refDate: new Date(now.getFullYear(), now.getMonth(), 0, 23, 59, 59),
50
+ });
47
51
  expect(
48
52
  CreditCardHelper.getExpirationState(
49
53
  CreditCardFactory({
@@ -15,16 +15,29 @@ export class CreditCardHelper {
15
15
  if (!creditCard.expiration_month || !creditCard.expiration_year) {
16
16
  return false;
17
17
  }
18
- const expirationDate = new Date(creditCard.expiration_year, creditCard.expiration_month - 1, 1);
19
- const limitDate = new Date();
20
- limitDate.setMonth(limitDate.getMonth() + 3);
21
- return limitDate.getTime() > expirationDate.getTime();
18
+ const expirationDate = new Date(
19
+ creditCard.expiration_year,
20
+ creditCard.expiration_month,
21
+ 0,
22
+ 23,
23
+ 59,
24
+ 59,
25
+ );
26
+ const limitDate = new Date(new Date().getFullYear(), new Date().getMonth() + 4, 0, 23, 59, 59);
27
+ return limitDate.getTime() >= expirationDate.getTime();
22
28
  }
23
29
 
24
30
  static isExpired(creditCard: CreditCard): boolean {
25
- const expirationDate = new Date(creditCard.expiration_year, creditCard.expiration_month - 1, 1);
31
+ const expirationDate = new Date(
32
+ creditCard.expiration_year,
33
+ creditCard.expiration_month,
34
+ 0,
35
+ 23,
36
+ 59,
37
+ 59,
38
+ );
26
39
  const now = new Date();
27
- return expirationDate.getTime() < now.getTime();
40
+ return expirationDate.getTime() <= now.getTime();
28
41
  }
29
42
 
30
43
  static getExpirationState(creditCard: CreditCard): CreditCardExpirationStatus {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "richie-education",
3
- "version": "2.25.0-b2.dev62",
3
+ "version": "2.25.0-b2.dev63",
4
4
  "description": "A CMS to build learning portals for Open Education",
5
5
  "main": "sandbox/manage.py",
6
6
  "scripts": {