-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/feature-updates
- Loading branch information
Showing
14 changed files
with
251 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
"conventionalCommits": true | ||
} | ||
}, | ||
"version": "7.11.0" | ||
"version": "7.11.1" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
packages/lambda-tiler/src/routes/__tests__/link.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { strictEqual } from 'node:assert'; | ||
import { afterEach, describe, it } from 'node:test'; | ||
|
||
import { ConfigProviderMemory } from '@basemaps/config'; | ||
import { Epsg } from '@basemaps/geo'; | ||
|
||
import { FakeData, Imagery3857 } from '../../__tests__/config.data.js'; | ||
import { mockRequest } from '../../__tests__/xyz.util.js'; | ||
import { handler } from '../../index.js'; | ||
import { ConfigLoader } from '../../util/config.loader.js'; | ||
|
||
describe('/v1/link/:tileSet', () => { | ||
const FakeTileSetName = 'tileset'; | ||
const config = new ConfigProviderMemory(); | ||
|
||
afterEach(() => { | ||
config.objects.clear(); | ||
}); | ||
|
||
/** | ||
* 3xx status responses | ||
*/ | ||
|
||
// tileset found, is raster type, has one layer, has '3857' entry, imagery found > 302 response | ||
it('success: redirect to pre-zoomed imagery', async (t) => { | ||
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config)); | ||
|
||
config.put(FakeData.tileSetRaster(FakeTileSetName)); | ||
config.put(Imagery3857); | ||
|
||
const req = mockRequest(`/v1/link/${FakeTileSetName}`); | ||
const res = await handler.router.handle(req); | ||
|
||
strictEqual(res.status, 302); | ||
strictEqual(res.statusDescription, 'Redirect to pre-zoomed imagery'); | ||
}); | ||
|
||
/** | ||
* 4xx status responses | ||
*/ | ||
|
||
// tileset not found > 404 response | ||
it('failure: tileset not found', async (t) => { | ||
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config)); | ||
|
||
const req = mockRequest(`/v1/link/${FakeTileSetName}`); | ||
const res = await handler.router.handle(req); | ||
|
||
strictEqual(res.status, 404); | ||
strictEqual(res.statusDescription, 'Tileset not found'); | ||
}); | ||
|
||
// tileset found, not raster type > 400 response | ||
it('failure: tileset must be raster type', async (t) => { | ||
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config)); | ||
|
||
config.put(FakeData.tileSetVector(FakeTileSetName)); | ||
|
||
const req = mockRequest(`/v1/link/${FakeTileSetName}`); | ||
const res = await handler.router.handle(req); | ||
|
||
strictEqual(res.status, 400); | ||
strictEqual(res.statusDescription, 'Tileset must be raster type'); | ||
}); | ||
|
||
// tileset found, is raster type, has more than one layer > 400 response | ||
it('failure: too many layers', async (t) => { | ||
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config)); | ||
|
||
const tileSet = FakeData.tileSetRaster(FakeTileSetName); | ||
|
||
// add another layer | ||
tileSet.layers.push(tileSet.layers[0]); | ||
|
||
config.put(tileSet); | ||
|
||
const req = mockRequest(`/v1/link/${FakeTileSetName}`); | ||
const res = await handler.router.handle(req); | ||
|
||
strictEqual(res.status, 400); | ||
strictEqual(res.statusDescription, 'Too many layers'); | ||
}); | ||
|
||
// tileset found, is raster type, has one layer, no '3857' entry > 400 response | ||
it("failure: no imagery for '3857' projection", async (t) => { | ||
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config)); | ||
|
||
const tileSet = FakeData.tileSetRaster(FakeTileSetName); | ||
|
||
// delete '3857' entry | ||
delete tileSet.layers[0][Epsg.Google.code]; | ||
|
||
config.put(tileSet); | ||
|
||
const req = mockRequest(`/v1/link/${FakeTileSetName}`); | ||
const res = await handler.router.handle(req); | ||
|
||
strictEqual(res.status, 400); | ||
strictEqual(res.statusDescription, "No imagery for '3857' projection"); | ||
}); | ||
|
||
// tileset found, is raster type, has one layer, has '3857' entry, imagery not found > 400 response | ||
it('failure: imagery not found', async (t) => { | ||
t.mock.method(ConfigLoader, 'getDefaultConfig', () => Promise.resolve(config)); | ||
|
||
config.put(FakeData.tileSetRaster(FakeTileSetName)); | ||
|
||
const req = mockRequest(`/v1/link/${FakeTileSetName}`); | ||
const res = await handler.router.handle(req); | ||
|
||
strictEqual(res.status, 400); | ||
strictEqual(res.statusDescription, 'Imagery not found'); | ||
}); | ||
}); |
Oops, something went wrong.