add time converter to match module
This commit is contained in:
parent
a6f7476599
commit
0d407216bc
|
@ -151,7 +151,14 @@ export class Time {
|
||||||
|
|
||||||
private setSchedule = (): void => {
|
private setSchedule = (): void => {
|
||||||
Object.keys(this.timeRequest.schedule).map((day) => {
|
Object.keys(this.timeRequest.schedule).map((day) => {
|
||||||
this.schedule[day] = this.timeRequest.schedule[day];
|
this.schedule[day] = this.timeConverter.toUtcDate(
|
||||||
|
new Date(
|
||||||
|
`${this.fromDate.getFullYear()}-${this.fromDate.getMonth()}-${this.fromDate.getDate()} ${
|
||||||
|
this.timeRequest.schedule[day]
|
||||||
|
}`,
|
||||||
|
),
|
||||||
|
this.timeRequest.timezone,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,7 @@ export class MatchQuery {
|
||||||
this.matchRequest,
|
this.matchRequest,
|
||||||
this.defaultParams.MARGIN_DURATION,
|
this.defaultParams.MARGIN_DURATION,
|
||||||
this.defaultParams.VALIDITY_DURATION,
|
this.defaultParams.VALIDITY_DURATION,
|
||||||
|
this.timeConverter,
|
||||||
);
|
);
|
||||||
this.time.init();
|
this.time.init();
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,7 @@ const mockGeorouter = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Geography entity', () => {
|
describe('Geography entity', () => {
|
||||||
|
|
|
@ -2,6 +2,9 @@ import { Time } from '../../../../domain/entities/ecosystem/time';
|
||||||
|
|
||||||
const MARGIN_DURATION = 900;
|
const MARGIN_DURATION = 900;
|
||||||
const VALIDITY_DURATION = 365;
|
const VALIDITY_DURATION = 365;
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
describe('Time entity', () => {
|
describe('Time entity', () => {
|
||||||
it('should be defined', () => {
|
it('should be defined', () => {
|
||||||
|
@ -11,6 +14,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(time).toBeDefined();
|
expect(time).toBeDefined();
|
||||||
});
|
});
|
||||||
|
@ -23,6 +27,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
time.init();
|
time.init();
|
||||||
expect(time.fromDate.getFullYear()).toBe(
|
expect(time.fromDate.getFullYear()).toBe(
|
||||||
|
@ -37,6 +42,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
time.init();
|
time.init();
|
||||||
expect(time.marginDurations['tue']).toBe(300);
|
expect(time.marginDurations['tue']).toBe(300);
|
||||||
|
@ -51,6 +57,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
time.init();
|
time.init();
|
||||||
expect(time.marginDurations['tue']).toBe(900);
|
expect(time.marginDurations['tue']).toBe(900);
|
||||||
|
@ -67,6 +74,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
time.init();
|
time.init();
|
||||||
expect(time.marginDurations['tue']).toBe(500);
|
expect(time.marginDurations['tue']).toBe(500);
|
||||||
|
@ -82,6 +90,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
time.init();
|
time.init();
|
||||||
expect(time.fromDate.getFullYear()).toBe(
|
expect(time.fromDate.getFullYear()).toBe(
|
||||||
|
@ -89,7 +98,12 @@ describe('Time entity', () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should throw an exception if no date is provided', () => {
|
it('should throw an exception if no date is provided', () => {
|
||||||
const time = new Time({}, MARGIN_DURATION, VALIDITY_DURATION);
|
const time = new Time(
|
||||||
|
{},
|
||||||
|
MARGIN_DURATION,
|
||||||
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
it('should throw an exception if punctual date is invalid', () => {
|
it('should throw an exception if punctual date is invalid', () => {
|
||||||
|
@ -99,6 +113,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -109,6 +124,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -120,6 +136,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -131,6 +148,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -142,6 +160,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -154,6 +173,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -168,6 +188,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
@ -180,6 +201,7 @@ describe('Time entity', () => {
|
||||||
},
|
},
|
||||||
MARGIN_DURATION,
|
MARGIN_DURATION,
|
||||||
VALIDITY_DURATION,
|
VALIDITY_DURATION,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(() => time.init()).toThrow();
|
expect(() => time.init()).toThrow();
|
||||||
});
|
});
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('AlgorithmFactoryCreator', () => {
|
describe('AlgorithmFactoryCreator', () => {
|
||||||
|
|
|
@ -12,7 +12,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -53,6 +57,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
class FakeSelector extends Selector {
|
class FakeSelector extends Selector {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('ClassicAlgorithmFactory', () => {
|
describe('ClassicAlgorithmFactory', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('ClassicGeoFilter', () => {
|
describe('ClassicGeoFilter', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('ClassicTimeFilter', () => {
|
describe('ClassicTimeFilter', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('ClassicWaypointCompleter', () => {
|
describe('ClassicWaypointCompleter', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('ClassicSelector', () => {
|
describe('ClassicSelector', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
class FakeCompleter extends Completer {
|
class FakeCompleter extends Completer {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
class FakeFilter extends Filter {
|
class FakeFilter extends Filter {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('JourneyCompleter', () => {
|
describe('JourneyCompleter', () => {
|
||||||
|
|
|
@ -22,7 +22,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -63,6 +67,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('Matcher', () => {
|
describe('Matcher', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn().mockImplementation(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
class FakeProcessor extends Processor {
|
class FakeProcessor extends Processor {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
describe('RouteCompleter', () => {
|
describe('RouteCompleter', () => {
|
||||||
|
|
|
@ -10,7 +10,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -51,6 +55,7 @@ const matchQuery: MatchQuery = new MatchQuery(
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
|
|
||||||
class FakeSelector extends Selector {
|
class FakeSelector extends Selector {
|
||||||
|
|
|
@ -35,7 +35,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultParams: IDefaultParams = {
|
const defaultParams: IDefaultParams = {
|
||||||
|
@ -106,6 +110,7 @@ describe('MatchUseCase', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(matches.total).toBe(3);
|
expect(matches.total).toBe(3);
|
||||||
|
@ -119,6 +124,7 @@ describe('MatchUseCase', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
).rejects.toBeInstanceOf(MatcherException);
|
).rejects.toBeInstanceOf(MatcherException);
|
||||||
|
|
|
@ -32,7 +32,11 @@ const mockGeorouterCreator = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const mockTimezoneFinder = {
|
const mockTimezoneFinder = {
|
||||||
timezones: jest.fn().mockImplementation(),
|
timezones: jest.fn().mockImplementation(() => ['Europe/Paris']),
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockTimeConverter = {
|
||||||
|
toUtcDate: jest.fn(),
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('Match query', () => {
|
describe('Match query', () => {
|
||||||
|
@ -54,6 +58,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery).toBeDefined();
|
expect(matchQuery).toBeDefined();
|
||||||
expect(matchQuery.mode).toBe(Mode.MATCH);
|
expect(matchQuery.mode).toBe(Mode.MATCH);
|
||||||
|
@ -78,6 +83,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.mode).toBe(Mode.PUBLISH_AND_MATCH);
|
expect(matchQuery.mode).toBe(Mode.PUBLISH_AND_MATCH);
|
||||||
});
|
});
|
||||||
|
@ -106,6 +112,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.exclusions.length).toBe(4);
|
expect(matchQuery.exclusions.length).toBe(4);
|
||||||
});
|
});
|
||||||
|
@ -129,6 +136,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.roles).toEqual([Role.DRIVER]);
|
expect(matchQuery.roles).toEqual([Role.DRIVER]);
|
||||||
});
|
});
|
||||||
|
@ -152,6 +160,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.roles).toEqual([Role.PASSENGER]);
|
expect(matchQuery.roles).toEqual([Role.PASSENGER]);
|
||||||
});
|
});
|
||||||
|
@ -176,6 +185,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.roles.length).toBe(2);
|
expect(matchQuery.roles.length).toBe(2);
|
||||||
expect(matchQuery.roles).toContain(Role.PASSENGER);
|
expect(matchQuery.roles).toContain(Role.PASSENGER);
|
||||||
|
@ -202,6 +212,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.requirement.seatsDriver).toBe(1);
|
expect(matchQuery.requirement.seatsDriver).toBe(1);
|
||||||
expect(matchQuery.requirement.seatsPassenger).toBe(2);
|
expect(matchQuery.requirement.seatsPassenger).toBe(2);
|
||||||
|
@ -234,6 +245,7 @@ describe('Match query', () => {
|
||||||
defaultParams,
|
defaultParams,
|
||||||
mockGeorouterCreator,
|
mockGeorouterCreator,
|
||||||
mockTimezoneFinder,
|
mockTimezoneFinder,
|
||||||
|
mockTimeConverter,
|
||||||
);
|
);
|
||||||
expect(matchQuery.algorithmSettings.algorithmType).toBe(
|
expect(matchQuery.algorithmSettings.algorithmType).toBe(
|
||||||
AlgorithmType.CLASSIC,
|
AlgorithmType.CLASSIC,
|
||||||
|
|
Loading…
Reference in New Issue