diff --git a/src/MongoManager.ts b/src/MongoManager.ts index 8f215c3..19e98c3 100644 --- a/src/MongoManager.ts +++ b/src/MongoManager.ts @@ -91,8 +91,17 @@ class MongoManager { ); } - async getLocation(id: string) { - throw new Error("Not implemented"); + async getLocation(id: string): Promise { + 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 { diff --git a/src/__unit-tests__/controller.test.ts b/src/__unit-tests__/controller.test.ts index 7cb3ed2..02acff7 100644 --- a/src/__unit-tests__/controller.test.ts +++ b/src/__unit-tests__/controller.test.ts @@ -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"); diff --git a/src/__unit-tests__/distanceMatrixService.test.ts b/src/__unit-tests__/distanceMatrixService.test.ts index 1595ecd..4a3d486 100644 --- a/src/__unit-tests__/distanceMatrixService.test.ts +++ b/src/__unit-tests__/distanceMatrixService.test.ts @@ -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", () => { @@ -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: [] } diff --git a/yarn.lock b/yarn.lock index 04590ef..03bf9a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"