mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 15:06:32 +00:00
test(server): narrow a partial ways answer the way the server build can, format three tests
This commit is contained in:
@@ -19,7 +19,10 @@ describe('the ski options column', () => {
|
||||
const idx = names.indexOf(TARGET);
|
||||
expect(idx).toBeGreaterThan(0);
|
||||
await migrateTo(orm, names[idx - 1] as string);
|
||||
await rawExec(orm, "INSERT INTO users (id, username, email, password_hash) VALUES (1, 'owner', 'owner@test', 'x')");
|
||||
await rawExec(
|
||||
orm,
|
||||
"INSERT INTO users (id, username, email, password_hash) VALUES (1, 'owner', 'owner@test', 'x')",
|
||||
);
|
||||
await rawExec(orm, "INSERT INTO trips (id, user_id, title) VALUES (10, 1, 'Alps')");
|
||||
await rawExec(orm, "INSERT INTO places (id, trip_id, name) VALUES (100, 10, 'Valley run')");
|
||||
await rawExec(orm, "INSERT INTO tours (place_id, tour_type, ski_discipline) VALUES (100, 'ski', 'alpine')");
|
||||
|
||||
@@ -500,11 +500,7 @@ describe('AdminController feature toggles', () => {
|
||||
[() => c.updateToursWanderer(user, { enabled: true }, req), 'admin.tours_wanderer', 'updateToursWanderer'],
|
||||
[() => c.updateToursHikingMap(user, { enabled: true }, req), 'admin.tours_hiking_map', 'updateToursHikingMap'],
|
||||
[() => c.updateToursCycleMap(user, { enabled: true }, req), 'admin.tours_cycle_map', 'updateToursCycleMap'],
|
||||
[
|
||||
() => c.updateToursSkiRouting(user, { enabled: true }, req),
|
||||
'admin.tours_ski_routing',
|
||||
'updateToursSkiRouting',
|
||||
],
|
||||
[() => c.updateToursSkiRouting(user, { enabled: true }, req), 'admin.tours_ski_routing', 'updateToursSkiRouting'],
|
||||
[() => c.updatePlacesPhotos(user, { enabled: true }, req), 'admin.places_photos', 'updatePlacesPhotos'],
|
||||
[
|
||||
() => c.updatePlacesAutocomplete(user, { enabled: true }, req),
|
||||
|
||||
@@ -146,8 +146,7 @@ describe.each([
|
||||
const request = skiRouteRequestSchema.parse({ legs: [{ from: point(), to: point() }], discipline });
|
||||
const profile = profileOf(request);
|
||||
const costs = compileProfile(profile, net);
|
||||
const modeOf = (step: Step) =>
|
||||
(step.dir === 0 ? costs.modeFwd[step.edge] : costs.modeBack[step.edge]) as number;
|
||||
const modeOf = (step: Step) => (step.dir === 0 ? costs.modeFwd[step.edge] : costs.modeBack[step.edge]) as number;
|
||||
let planned = 0;
|
||||
for (let pair = 0; pair < PAIRS; pair++) {
|
||||
const from = point();
|
||||
|
||||
@@ -970,7 +970,7 @@ describe('trekPlacesWays', () => {
|
||||
const ids = Array.from({ length: 1400 }, (_, index) => index + 1);
|
||||
const answer = await trekPlacesWays(ids);
|
||||
expect(calls).toHaveLength(2);
|
||||
if (answer.complete) throw new Error('expected an answer that stopped part way');
|
||||
if (answer.complete !== false) throw new Error('expected an answer that stopped part way');
|
||||
expect(answer.ways).toEqual([{ type: 'way', id: 2, tags: { surface: 'gravel' } }]);
|
||||
expect(answer.unanswered).toEqual(ids.slice(500));
|
||||
expect(trekPlacesMiss(answer.failure)).toBe('failed');
|
||||
|
||||
Reference in New Issue
Block a user