fix(map): accept canonical gateway endpoints
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { parseProviderEndpoint } from "../dist/providerEndpoint.js";
|
||||
|
||||
const attributions = [{ html: "provider", collapsible: true }];
|
||||
|
||||
test("provider endpoint accepts the canonical string asset identifiers", () => {
|
||||
const imagery = parseProviderEndpoint({
|
||||
assetId: "2",
|
||||
type: "IMAGERY",
|
||||
externalType: "BING",
|
||||
credentialMode: "gateway",
|
||||
options: {
|
||||
url: "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial",
|
||||
mapStyle: "Aerial",
|
||||
},
|
||||
attributions,
|
||||
}, 2, "imagery");
|
||||
const terrain = parseProviderEndpoint({
|
||||
assetId: "1",
|
||||
type: "TERRAIN",
|
||||
credentialMode: "gateway",
|
||||
url: "https://assets.ion.cesium.com/terrain/",
|
||||
attributions,
|
||||
}, 1, "terrain");
|
||||
const buildings = parseProviderEndpoint({
|
||||
assetId: "96188",
|
||||
type: "3DTILES",
|
||||
credentialMode: "gateway",
|
||||
url: "https://assets.ion.cesium.com/buildings/tileset.json",
|
||||
attributions,
|
||||
}, 96188, "buildings");
|
||||
|
||||
assert.equal(imagery.assetId, "2");
|
||||
assert.equal(terrain.assetId, "1");
|
||||
assert.equal(buildings.assetId, "96188");
|
||||
});
|
||||
|
||||
test("provider endpoint rejects numeric, mismatched and credential-bearing shapes", () => {
|
||||
for (const document of [
|
||||
{
|
||||
assetId: 1,
|
||||
type: "TERRAIN",
|
||||
credentialMode: "gateway",
|
||||
url: "https://assets.ion.cesium.com/terrain/",
|
||||
attributions,
|
||||
},
|
||||
{
|
||||
assetId: "2",
|
||||
type: "TERRAIN",
|
||||
credentialMode: "gateway",
|
||||
url: "https://assets.ion.cesium.com/terrain/",
|
||||
attributions,
|
||||
},
|
||||
{
|
||||
assetId: "1",
|
||||
type: "TERRAIN",
|
||||
credentialMode: "browser",
|
||||
url: "https://assets.ion.cesium.com/terrain/",
|
||||
attributions,
|
||||
},
|
||||
]) {
|
||||
assert.throws(
|
||||
() => parseProviderEndpoint(document, 1, "terrain"),
|
||||
/map_provider_contract_mismatch/,
|
||||
);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user