Merge pull request #2199 from automatisch/aut-1350-startTrialPeriod
test(user): write test for startTrialPeriod
This commit is contained in:
@@ -407,7 +407,7 @@ class User extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
async startTrialPeriod() {
|
||||
startTrialPeriod() {
|
||||
this.trialExpiryDate = DateTime.now().plus({ days: 30 }).toISODate();
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ class User extends Base {
|
||||
await this.generateHash();
|
||||
|
||||
if (appConfig.isCloud) {
|
||||
await this.startTrialPeriod();
|
||||
this.startTrialPeriod();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -856,4 +856,23 @@ describe('User model', () => {
|
||||
expect(user.password).toBe(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
it('startTrialPeriod should assign trialExpiryDate 30 days from now', () => {
|
||||
vi.useFakeTimers();
|
||||
|
||||
const date = DateTime.fromObject(
|
||||
{ year: 2024, month: 11, day: 14, hour: 16 },
|
||||
{ zone: 'UTC+0' }
|
||||
);
|
||||
|
||||
vi.setSystemTime(date);
|
||||
|
||||
const user = new User();
|
||||
|
||||
user.startTrialPeriod();
|
||||
|
||||
expect(user.trialExpiryDate).toBe('2024-12-14');
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user