diff --git a/badges/coverage-functions.svg b/badges/coverage-functions.svg
index fd6da43..66c721c 100644
--- a/badges/coverage-functions.svg
+++ b/badges/coverage-functions.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/badges/coverage-lines.svg b/badges/coverage-lines.svg
index 16a6ff5..fa8a6eb 100644
--- a/badges/coverage-lines.svg
+++ b/badges/coverage-lines.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/badges/coverage-statements.svg b/badges/coverage-statements.svg
index a2a43b3..4d9345e 100644
--- a/badges/coverage-statements.svg
+++ b/badges/coverage-statements.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/badges/coverage-total.svg b/badges/coverage-total.svg
index ab2b88a..cb54e8b 100644
--- a/badges/coverage-total.svg
+++ b/badges/coverage-total.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/jest.config.js b/jest.config.js
index 7530fcb..134cee4 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -6,7 +6,8 @@ const tsJestTransformCfg = createDefaultPreset().transform;
module.exports = {
collectCoverageFrom: ["src/**/*.ts"],
coverageReporters: ["text", "lcov", "json-summary"],
- testMatch: ["**/test/**/*.test.ts"],
+ // Using https://jestjs.io/docs/configuration#rootdir-string
+ testMatch: ["/test/**/*.test.ts"],
testEnvironment: "node",
transform: {
...tsJestTransformCfg,
diff --git a/src/McRAPTOR.ts b/src/McRAPTOR.ts
index 2b758b4..669a5ae 100644
--- a/src/McRAPTOR.ts
+++ b/src/McRAPTOR.ts
@@ -1,14 +1,11 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
-import BaseRAPTOR from "./base";
+import BaseRAPTOR, { IRAPTOR } from "./base";
import { Bag, Criterion, Id, IRAPTORData, IStop, Journey, JourneyStep, Label, makeJSComparable, Route } from "./structures";
-export default class McRAPTOR extends BaseRAPTOR<
- TimeVal,
- SI,
- RI,
- V,
- CA
-> {
+export default class McRAPTOR
+ extends BaseRAPTOR
+ implements IRAPTOR
+{
/** @description A {@link Label} Bags_i(SI) stores earliest known arrival times and best values for criteria at stop `SI` with up to `i` trips. */
protected bags: Map>>[] = [];
diff --git a/src/RAPTOR.ts b/src/RAPTOR.ts
index 4f8b3d6..963a1bb 100644
--- a/src/RAPTOR.ts
+++ b/src/RAPTOR.ts
@@ -1,11 +1,11 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
-import BaseRAPTOR from "./base";
+import BaseRAPTOR, { IRAPTOR } from "./base";
import { Id, IStop, Journey, JourneyStep, Label, makeJSComparable, Route } from "./structures";
/**
* @description A RAPTOR instance
*/
-export default class RAPTOR extends BaseRAPTOR {
+export default class RAPTOR extends BaseRAPTOR implements IRAPTOR {
/** @description A {@link Label} Ti(SI) represents the earliest known arrival time at stop SI with up to i trips. */
protected multiLabel: Map>[] = [];
diff --git a/src/base.ts b/src/base.ts
index 6543f2f..48b83f8 100644
--- a/src/base.ts
+++ b/src/base.ts
@@ -8,11 +8,28 @@ interface RAPTORRunSettings {
maxTransferLength: number;
}
+interface IRAPTOR {
+ /**
+ * Run a RAPTOR query
+ * @param ps Query source
+ * @param pt Query target ; can be `null` to set query mode to "One-To-All".
+ */
+ run(ps: SI, pt: SI | null, departureTime: TimeVal, settings: RAPTORRunSettings, rounds: number): void;
+ /**
+ * Get best journeys from a target stop {@link pt} after running the algorithm with {@link run}.
+ * @param pt Target stop to get best journeys to
+ * @returns A list of journeys for each round.
+ */
+ getBestJourneys(pt: SI): Journey[][];
+}
+
/**
* @description A RAPTOR instance
* @template TimeVal Time representation internal type, its full type is {@link Time}.
*/
-export default class BaseRAPTOR {
+export default class BaseRAPTOR
+ implements Pick, "run">
+{
static defaultRounds = 6;
protected runParams: {
@@ -115,11 +132,6 @@ export default class BaseRAPTOR[][] {
- throw new Error("Not implemented");
- }
}
-export type { RAPTORRunSettings };
+export type { IRAPTOR, RAPTORRunSettings };
diff --git a/test/McSharedRAPTOR.test.ts b/test/McSharedRAPTOR.test.ts
index d91de20..fc39515 100644
--- a/test/McSharedRAPTOR.test.ts
+++ b/test/McSharedRAPTOR.test.ts
@@ -14,7 +14,7 @@ import {
TimeScal,
Timestamp,
} from "../src";
-import BaseRAPTOR from "../src/base";
+import BaseRAPTOR, { IRAPTOR } from "../src/base";
import { TestDataset } from "./assets/asset";
import BTOneLine from "./assets/BTOneLine";
import BTTwoLines from "./assets/BTTwoLines";
@@ -22,9 +22,9 @@ import FDOneLine from "./assets/FDOneLine";
import FDTwoLines from "./assets/FDTwoLines";
import oneLine from "./assets/oneLine";
import oneLineOTA from "./assets/oneLineOTA";
+import specialCases from "./assets/specialCases";
import twoLines from "./assets/twoLines";
import twoLinesOTA from "./assets/twoLinesOTA";
-import specialCases from "./assets/specialCases";
describe("McSharedRAPTOR", () => {
// Same as RAPTOR
@@ -46,7 +46,7 @@ describe("McSharedRAPTOR", () => {
for (const journeys of res) expect(journeys.length || 1).toBe(1);
test.validate(
res.map((journeys) => (journeys.length ? [journeys[0]] : [])),
- sharedRaptorInstance as BaseRAPTOR,
+ sharedRaptorInstance as BaseRAPTOR & IRAPTOR,
);
}
});
diff --git a/test/SharedRAPTOR.test.ts b/test/SharedRAPTOR.test.ts
index 7080730..f240592 100644
--- a/test/SharedRAPTOR.test.ts
+++ b/test/SharedRAPTOR.test.ts
@@ -1,6 +1,6 @@
import { describe } from "@jest/globals";
import { InternalTimeInt, SharedRAPTOR, SharedRAPTORData, SharedTime, sharedTimeIntOrderLow, sharedTimeScal, TimeScal, Timestamp } from "../src";
-import BaseRAPTOR from "../src/base";
+import BaseRAPTOR, { IRAPTOR } from "../src/base";
import { TestDataset } from "./assets/asset";
import oneLine from "./assets/oneLine";
import oneLineOTA from "./assets/oneLineOTA";
@@ -23,7 +23,10 @@ describe("SharedRAPTOR", () => {
for (const test of asset.tests) {
sharedRaptorInstance.run(...test.params);
const res = test.params[1] !== null ? sharedRaptorInstance.getBestJourneys(test.params[1]) : [];
- test.validate(res, sharedRaptorInstance as BaseRAPTOR);
+ test.validate(
+ res,
+ sharedRaptorInstance as BaseRAPTOR & IRAPTOR,
+ );
}
});
}
diff --git a/test/assets/asset.d.ts b/test/assets/asset.d.ts
index 0c26108..e661ff1 100644
--- a/test/assets/asset.d.ts
+++ b/test/assets/asset.d.ts
@@ -1,13 +1,13 @@
import { McRAPTOR, RAPTOR, RAPTORData } from "../../src";
-import BaseRAPTOR from "../../src/base";
+import BaseRAPTOR, { IRAPTOR } from "../../src/base";
interface TestAsset {
data: ConstructorParameters>;
tests: {
params: Parameters["run"]>;
validate: (
- res: ReturnType["getBestJourneys"]>,
- raptorInstance: InstanceType>,
+ res: ReturnType["getBestJourneys"]>,
+ raptorInstance: InstanceType> & IRAPTOR,
) => void;
}[];
}
diff --git a/test/assets/utils.ts b/test/assets/utils.ts
index 06a78cd..4d73686 100644
--- a/test/assets/utils.ts
+++ b/test/assets/utils.ts
@@ -1,5 +1,5 @@
import { Journey, Time } from "../../src";
-import BaseRAPTOR from "../../src/base";
+import BaseRAPTOR, { IRAPTOR } from "../../src/base";
import { McTestAsset, TestAsset } from "./asset";
const validateWithoutCriteria =
@@ -26,7 +26,7 @@ const validateWithoutCriteria =
});
validate(
journeysWithoutCriteria as Parameters["tests"][number]["validate"]>[0],
- rap as unknown as BaseRAPTOR,
+ rap as unknown as BaseRAPTOR & IRAPTOR,
);
return [journeysWithoutCriteria, res.map((journeys, k) => journeys.filter((j) => j !== journeysWithoutCriteria[k][0]))];
diff --git a/test/base.test.ts b/test/base.test.ts
index 5a2fd6b..47862aa 100644
--- a/test/base.test.ts
+++ b/test/base.test.ts
@@ -24,10 +24,6 @@ describe("Base RAPTOR should not be usable", () => {
expect(() => {
(raptorInstance as unknown as { traverseFootPaths: BaseRAPTOR["traverseFootPaths"] }).traverseFootPaths(0, new Stop(0, [], []));
}).toThrow("Not implemented");
-
- expect(() => {
- (raptorInstance as unknown as { getBestJourneys: BaseRAPTOR["getBestJourneys"] }).getBestJourneys(0);
- }).toThrow("Not implemented");
});
});