From 9181a5b3bc76916da253b64f6bbbb21770ad6dce Mon Sep 17 00:00:00 2001 From: HendrikThePendric Date: Mon, 4 Mar 2024 15:48:01 +0100 Subject: [PATCH] Revert "Revert "fix: align mock implementation with getWorkerInstance"" This reverts commit 49b4cb314c76a528ca2efba6074859370212231e. --- src/layers/__tests__/EarthEngine.spec.js | 30 +++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/layers/__tests__/EarthEngine.spec.js b/src/layers/__tests__/EarthEngine.spec.js index be63a3b7..724fc187 100644 --- a/src/layers/__tests__/EarthEngine.spec.js +++ b/src/layers/__tests__/EarthEngine.spec.js @@ -4,13 +4,15 @@ const urlFormat = 'https://earthengine.googleapis.com/v1alpha/projects/earthengine-legacy/maps/.../tiles/{z}/{x}/{y}' // Mock out EE Worker - import.meta not supported in jest -jest.mock('../../earthengine/ee_worker_loader', () => ({ - __esModule: true, - default: async () => async () => - new (class EarthEngineWorkerMock { - getTileUrl = async () => urlFormat - })(), -})) +jest.mock('../../earthengine/ee_worker_loader', () => { + class EarthEngineWorkerMock { + getTileUrl = async () => urlFormat + } + return { + __esModule: true, + default: async () => async () => EarthEngineWorkerMock, + } +}) const token = { access_token: 'abc', @@ -99,12 +101,22 @@ describe('EarthEngine', () => { expect(layer.getId()).not.toBeNull() }) - it('Should add to map', async () => { + it.only('Should add to map', async () => { + console.log('a') const layer = new EarthEngine(options) - await layer.addTo(mockMap) + console.log('b') + try { + console.log(layer) + await layer.addTo(mockMap) + } catch (error) { + console.log('IT WENT WRONG', error) + } + console.log('c') expect(layer.getMap()).toBe(mockMap) + console.log('d') expect(layer.getMapGL()).toBe(mockMapGL) + console.log('e') await expect(layer.options.getAuthToken()).resolves.toEqual(token) })