mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
fixing tests
This commit is contained in:
parent
8b6a367257
commit
c383d71e4a
@ -1,23 +1,14 @@
|
|||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {JobManager} from '../../../../../src/backend/model/jobs/JobManager';
|
import {JobScheduleDTO, JobTriggerType} from '../../../src/common/entities/job/JobScheduleDTO';
|
||||||
import {JobScheduleDTO, JobTriggerType} from '../../../../../src/common/entities/job/JobScheduleDTO';
|
|
||||||
|
|
||||||
class JobManagerSpec extends JobManager {
|
describe('JobScheduleDTO', () => {
|
||||||
|
|
||||||
public getDateFromSchedule(refDate: Date, schedule: JobScheduleDTO): Date {
|
|
||||||
return super.getDateFromSchedule(refDate, schedule);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('JobManager', () => {
|
|
||||||
|
|
||||||
it('should get date from schedule', async () => {
|
it('should get date from schedule', async () => {
|
||||||
const tm = new JobManagerSpec();
|
|
||||||
|
|
||||||
const refDate = new Date(2019, 7, 18, 5, 10, 10, 0); // its a sunday
|
const refDate = new Date(2019, 7, 18, 5, 10, 10, 0); // its a sunday
|
||||||
|
|
||||||
|
|
||||||
expect(tm.getDateFromSchedule(refDate, <any>{
|
expect(JobScheduleDTO.getNextRunningDate(refDate, <any>{
|
||||||
trigger: {
|
trigger: {
|
||||||
type: JobTriggerType.scheduled,
|
type: JobTriggerType.scheduled,
|
||||||
time: (new Date(2019, 7, 18, 5, 10)).getTime()
|
time: (new Date(2019, 7, 18, 5, 10)).getTime()
|
||||||
@ -30,7 +21,7 @@ describe('JobManager', () => {
|
|||||||
|
|
||||||
let h = 10;
|
let h = 10;
|
||||||
let m = 5;
|
let m = 5;
|
||||||
expect(tm.getDateFromSchedule(refDate, <any>{
|
expect(JobScheduleDTO.getNextRunningDate(refDate, <any>{
|
||||||
trigger: {
|
trigger: {
|
||||||
type: JobTriggerType.periodic,
|
type: JobTriggerType.periodic,
|
||||||
atTime: (h * 60 + m) * 60 * 1000,
|
atTime: (h * 60 + m) * 60 * 1000,
|
||||||
@ -41,7 +32,7 @@ describe('JobManager', () => {
|
|||||||
h = 2;
|
h = 2;
|
||||||
m = 5;
|
m = 5;
|
||||||
nextDay = 18 + dayOfWeek + 1;
|
nextDay = 18 + dayOfWeek + 1;
|
||||||
expect(tm.getDateFromSchedule(refDate, <any>{
|
expect(JobScheduleDTO.getNextRunningDate(refDate, <any>{
|
||||||
trigger: {
|
trigger: {
|
||||||
type: JobTriggerType.periodic,
|
type: JobTriggerType.periodic,
|
||||||
atTime: (h * 60 + m) * 60 * 1000,
|
atTime: (h * 60 + m) * 60 * 1000,
|
||||||
@ -52,7 +43,7 @@ describe('JobManager', () => {
|
|||||||
h = 5;
|
h = 5;
|
||||||
m = 10;
|
m = 10;
|
||||||
nextDay = 18 + dayOfWeek + 1;
|
nextDay = 18 + dayOfWeek + 1;
|
||||||
expect(tm.getDateFromSchedule(refDate, <any>{
|
expect(JobScheduleDTO.getNextRunningDate(refDate, <any>{
|
||||||
trigger: {
|
trigger: {
|
||||||
type: JobTriggerType.periodic,
|
type: JobTriggerType.periodic,
|
||||||
atTime: (h * 60 + m) * 60 * 1000,
|
atTime: (h * 60 + m) * 60 * 1000,
|
||||||
@ -64,7 +55,7 @@ describe('JobManager', () => {
|
|||||||
{
|
{
|
||||||
const h = 10;
|
const h = 10;
|
||||||
const m = 5;
|
const m = 5;
|
||||||
expect(tm.getDateFromSchedule(refDate, <any>{
|
expect(JobScheduleDTO.getNextRunningDate(refDate, <any>{
|
||||||
trigger: {
|
trigger: {
|
||||||
type: JobTriggerType.periodic,
|
type: JobTriggerType.periodic,
|
||||||
atTime: (h * 60 + m) * 60 * 1000,
|
atTime: (h * 60 + m) * 60 * 1000,
|
||||||
@ -75,7 +66,7 @@ describe('JobManager', () => {
|
|||||||
{
|
{
|
||||||
const h = 2;
|
const h = 2;
|
||||||
const m = 5;
|
const m = 5;
|
||||||
expect(tm.getDateFromSchedule(refDate, <any>{
|
expect(JobScheduleDTO.getNextRunningDate(refDate, <any>{
|
||||||
trigger: {
|
trigger: {
|
||||||
type: JobTriggerType.periodic,
|
type: JobTriggerType.periodic,
|
||||||
atTime: (h * 60 + m) * 60 * 1000,
|
atTime: (h * 60 + m) * 60 * 1000,
|
||||||
@ -84,5 +75,4 @@ describe('JobManager', () => {
|
|||||||
})).to.be.deep.equal((new Date(2019, 7, 19, h, m, 0)));
|
})).to.be.deep.equal((new Date(2019, 7, 19, h, m, 0)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user