Skip to content

Commit

Permalink
Revert "Revert "fix: align mock implementation with getWorkerInstance""
Browse files Browse the repository at this point in the history
This reverts commit 49b4cb3.
  • Loading branch information
HendrikThePendric committed Mar 4, 2024
1 parent 49b4cb3 commit 9181a5b
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/layers/__tests__/EarthEngine.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit 9181a5b

Please sign in to comment.