-
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.
feat(lambda-tiler): allow relative sprites and glyphs (#2071)
* feat(lambda-tiler): allow relative sprites and glyphs * refactor: improve unit tests for xyz requests
- Loading branch information
Showing
3 changed files
with
91 additions
and
44 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/lambda-tiler/src/__test__/tile.style.json.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,40 @@ | ||
import { Env } from '@basemaps/shared'; | ||
import o from 'ospec'; | ||
import { convertRelativeUrl } from '../routes/tile.style.json.js'; | ||
|
||
o.spec('TileStyleJson', () => { | ||
const host = 'https://tiles.test'; | ||
let originalHost: string | undefined; | ||
o.beforeEach(() => { | ||
originalHost = process.env[Env.PublicUrlBase]; | ||
process.env[Env.PublicUrlBase] = host; | ||
}); | ||
|
||
o.afterEach(() => { | ||
process.env[Env.PublicUrlBase] = originalHost; | ||
}); | ||
|
||
o('should not convert empty urls', () => { | ||
o(convertRelativeUrl()).equals(''); | ||
o(convertRelativeUrl('')).equals(''); | ||
o(convertRelativeUrl(undefined)).equals(''); | ||
}); | ||
|
||
o('should only convert relative urls', () => { | ||
o(convertRelativeUrl('/foo')).equals('https://tiles.test/foo'); | ||
o(convertRelativeUrl('/bar/baz/')).equals('https://tiles.test/bar/baz/'); | ||
}); | ||
|
||
o('should only convert with api keys', () => { | ||
o(convertRelativeUrl('/foo', 'abc')).equals('https://tiles.test/foo?api=abc'); | ||
o(convertRelativeUrl('/bar/baz/', 'abc')).equals('https://tiles.test/bar/baz/?api=abc'); | ||
}); | ||
|
||
o('should convert with other query params', () => { | ||
o(convertRelativeUrl('/foo?bar=baz', 'abc')).equals('https://tiles.test/foo?bar=baz&api=abc'); | ||
}); | ||
|
||
o('should not convert full urls', () => { | ||
o(convertRelativeUrl('https://foo.com/foo?bar=baz', 'abc')).equals('https://foo.com/foo?bar=baz'); | ||
}); | ||
}); |
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