Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/MongoManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,17 @@ class MongoManager {
);
}

async getLocation(id: string) {
throw new Error("Not implemented");
async getLocation(id: string): Promise<object> {
console.info("Get location");
let location: object;
try {
location = await this.database
.collection(LOCATION_UPDATES_COLLECTION_NAME)
.findOne({ _id: id });
} catch (err) {
console.error(`Error getting location with _id ${id}`, err);
}
return location;
}

async addLocationUpdate(eta, locationUpdate): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion src/__unit-tests__/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import config = require("config");
import mbxMatrix = require("@mapbox/mapbox-sdk/services/matrix");

jest.mock("@mapbox/mapbox-sdk/services/matrix");
jest.mock("../mongoManager");
jest.mock("../MongoManager");
jest.mock("../distanceMatrixService");
jest.mock("../twiageApiService");

Expand Down
12 changes: 9 additions & 3 deletions src/__unit-tests__/distanceMatrixService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import DistanceMatrixService, {
import MongoManager from "../MongoManager";

jest.mock("@mapbox/mapbox-sdk/services/matrix");
jest.mock("../mongoManager");
jest.mock("../MongoManager");

describe("DistanceMatrixService", () => {
describe("constructor", () => {
Expand Down Expand Up @@ -52,8 +52,14 @@ describe("DistanceMatrixService", () => {
const expectedMapboxMatrixData = {
body: {
code: "Ok",
distances: [[0, 139.9], [49, 0]],
durations: [[0, expectedEtaInSeconds], [25.5, 0]],
distances: [
[0, 139.9],
[49, 0]
],
durations: [
[0, expectedEtaInSeconds],
[25.5, 0]
],
destinations: [
{ distance: 2.713771455, name: "", location: [] },
{ distance: 1.453423572, name: "", location: [] }
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1613,9 +1613,9 @@ async-limiter@~1.0.0:
integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==

async@^2.0.0:
version "2.6.3"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff"
integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==
version "2.6.4"
resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221"
integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==
dependencies:
lodash "^4.17.14"

Expand Down Expand Up @@ -4803,9 +4803,9 @@ lodash.unescape@4.0.1:
integrity sha1-vyJJiGzlFM2hEvrpIYzcBlIR/Jw=

lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.8.0:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==

lolex@^4.2.0:
version "4.2.0"
Expand Down