Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
code review fixes: move initialization to beforeEach and use local re…
Browse files Browse the repository at this point in the history
…source

Signed-off-by: Jonathan Stichbury <[email protected]>
  • Loading branch information
nzjony committed Aug 23, 2021
1 parent 5a44545 commit 715bad5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions @here/harp-mapview/test/PoiRendererTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ describe("PoiRenderer", function () {
}
} as THREE.WebGLRenderer;
const mapViewStub = sinon.createStubInstance(MapView);
const poiManager = new PoiManager((mapViewStub as any) as MapView);
const testImageName = "testImage";
const mapEnv = new Env();

const createPointLabel = (name: string) => {
return {
poiInfo: {
Expand All @@ -127,23 +124,29 @@ describe("PoiRenderer", function () {
} as TextElement;
};

let x = 1;
let y = 1;

const addRandomImageToCache = (
testCache: MapViewImageCache,
name: string,
load: boolean
) => {
// Note, the images must be unique, otherwise the test will fail, because the internal
// caching mechanism of the ImageCache will have already loaded the image.
return testCache.addImage(name, `https://picsum.photos/${x++}/${y++}`, load);
return testCache.addImage(
name,
`/@here/harp-mapview/test/resources/headshot.jpg`,
load
);
};
let poiManager: PoiManager;
let mapEnv: Env;
let testCache: MapViewImageCache;
beforeEach(() => {
poiManager = new PoiManager((mapViewStub as any) as MapView);
mapEnv = new Env();
testCache = new MapViewImageCache();
});

it("poi is valid when in cache and loading started", async function () {
this.timeout(5000);

const testCache = new MapViewImageCache();
const testImageItem = addRandomImageToCache(testCache, testImageName, true);
const caches = [testCache];
const poiRenderer = new PoiRenderer(webGLRenderer, poiManager, caches);
Expand All @@ -168,7 +171,6 @@ describe("PoiRenderer", function () {
it("poi is invalid when not in cache, adding to cache means it will load", async function () {
this.timeout(5000);

const testCache = new MapViewImageCache();
// Empty cache for now
const caches = [testCache];
const poiRenderer = new PoiRenderer(webGLRenderer, poiManager, caches);
Expand Down

0 comments on commit 715bad5

Please sign in to comment.