@@ -20,28 +20,29 @@ describe("computeHasCesiumIonAsset", () => {
2020 expect ( computeHasCesiumIonAsset ( { tiles : [ ] } ) ) . toBe ( false ) ;
2121 } ) ;
2222
23- test ( "returns true for cesium_ion tile type" , ( ) => {
23+ test ( "returns true for cesium_ion tile type with valid assetId " , ( ) => {
2424 expect (
25- computeHasCesiumIonAsset ( { tiles : [ { id : "" , type : "cesium_ion" } ] } ) ,
25+ computeHasCesiumIonAsset (
26+ { tiles : [ { id : "" , type : "cesium_ion" , cesiumIonAssetId : 12345 } ] } ,
27+ undefined ,
28+ "my-token" ,
29+ ) ,
2630 ) . toBe ( true ) ;
2731 } ) ;
2832
29- test ( "returns true for cesium_ion_default tile type" , ( ) => {
33+ test ( "returns true for cesium_ion_default tile type when token present " , ( ) => {
3034 expect (
31- computeHasCesiumIonAsset ( {
32- tiles : [ { id : "" , type : "cesium_ion_default" } ] ,
33- } ) ,
35+ computeHasCesiumIonAsset (
36+ { tiles : [ { id : "" , type : "cesium_ion_default" } ] } ,
37+ undefined ,
38+ "my-token" ,
39+ ) ,
3440 ) . toBe ( true ) ;
3541 } ) ;
3642
37- test ( "returns true for legacy tile types" , ( ) => {
38- for ( const type of [
39- "default" ,
40- "default_road" ,
41- "default_label" ,
42- "black_marble" ,
43- ] ) {
44- expect ( computeHasCesiumIonAsset ( { tiles : [ { id : "" , type } ] } ) ) . toBe (
43+ test ( "returns true for legacy tile types when token present" , ( ) => {
44+ for ( const type of [ "default" , "default_road" , "default_label" , "black_marble" ] ) {
45+ expect ( computeHasCesiumIonAsset ( { tiles : [ { id : "" , type } ] } , undefined , "my-token" ) ) . toBe (
4546 true ,
4647 ) ;
4748 }
@@ -65,14 +66,23 @@ describe("computeHasCesiumIonAsset", () => {
6566 ) . toBe ( true ) ;
6667 } ) ;
6768
68- test ( "returns true for cesiumion terrain type when enabled " , ( ) => {
69+ test ( "returns true for cesiumion terrain type with ionAsset " , ( ) => {
6970 expect (
7071 computeHasCesiumIonAsset ( {
7172 terrain : { enabled : true , type : "cesiumion" } ,
72- } ) ,
73+ assets : { cesium : { terrain : { ionAsset : "1" } } } ,
74+ } as any ) ,
7375 ) . toBe ( true ) ;
7476 } ) ;
7577
78+ test ( "returns false for cesiumion terrain type without ionAsset or ionUrl" , ( ) => {
79+ expect (
80+ computeHasCesiumIonAsset ( {
81+ terrain : { enabled : true , type : "cesiumion" } ,
82+ } ) ,
83+ ) . toBe ( false ) ;
84+ } ) ;
85+
7686 test ( "returns false for cesium terrain when disabled" , ( ) => {
7787 expect (
7888 computeHasCesiumIonAsset ( {
@@ -111,9 +121,7 @@ describe("computeHasCesiumIonAsset", () => {
111121 describe ( "layers" , ( ) => {
112122 test ( "returns true for osm-buildings layer" , ( ) => {
113123 expect (
114- computeHasCesiumIonAsset ( undefined , [
115- makeSimple ( { type : "osm-buildings" } ) ,
116- ] as any ) ,
124+ computeHasCesiumIonAsset ( undefined , [ makeSimple ( { type : "osm-buildings" } ) ] as any ) ,
117125 ) . toBe ( true ) ;
118126 } ) ;
119127
@@ -135,9 +143,7 @@ describe("computeHasCesiumIonAsset", () => {
135143
136144 test ( "returns false for google-photorealistic with no provider (google API path)" , ( ) => {
137145 expect (
138- computeHasCesiumIonAsset ( undefined , [
139- makeSimple ( { type : "google-photorealistic" } ) ,
140- ] as any ) ,
146+ computeHasCesiumIonAsset ( undefined , [ makeSimple ( { type : "google-photorealistic" } ) ] as any ) ,
141147 ) . toBe ( false ) ;
142148 } ) ;
143149
@@ -175,9 +181,7 @@ describe("computeHasCesiumIonAsset", () => {
175181 } ) ;
176182
177183 test ( "returns false for layer with no data" , ( ) => {
178- expect ( computeHasCesiumIonAsset ( undefined , [ makeSimple ( ) ] as any ) ) . toBe (
179- false ,
180- ) ;
184+ expect ( computeHasCesiumIonAsset ( undefined , [ makeSimple ( ) ] as any ) ) . toBe ( false ) ;
181185 } ) ;
182186 } ) ;
183187
@@ -221,18 +225,19 @@ describe("computeHasCesiumIonAsset", () => {
221225
222226 test ( "returns true when only tile uses ion" , ( ) => {
223227 expect (
224- computeHasCesiumIonAsset ( { tiles : [ { id : "" , type : "default" } ] } , [
225- makeSimple ( { type : "geojson" } ) ,
226- ] as any ) ,
228+ computeHasCesiumIonAsset (
229+ { tiles : [ { id : "" , type : "default" } ] } ,
230+ [ makeSimple ( { type : "geojson" } ) ] as any ,
231+ "my-token" ,
232+ ) ,
227233 ) . toBe ( true ) ;
228234 } ) ;
229235
230236 test ( "returns true when only terrain uses ion" , ( ) => {
231237 expect (
232- computeHasCesiumIonAsset (
233- { terrain : { enabled : true , type : "cesium" } } ,
234- [ makeSimple ( { type : "geojson" } ) ] as any ,
235- ) ,
238+ computeHasCesiumIonAsset ( { terrain : { enabled : true , type : "cesium" } } , [
239+ makeSimple ( { type : "geojson" } ) ,
240+ ] as any ) ,
236241 ) . toBe ( true ) ;
237242 } ) ;
238243
@@ -242,4 +247,48 @@ describe("computeHasCesiumIonAsset", () => {
242247 expect ( computeHasCesiumIonAsset ( undefined , [ ] ) ) . toBe ( false ) ;
243248 } ) ;
244249 } ) ;
250+
251+ describe ( "token and assetId gating" , ( ) => {
252+ test ( "returns false for cesium_ion tile with no cesiumIonAssetId" , ( ) => {
253+ expect (
254+ computeHasCesiumIonAsset (
255+ { tiles : [ { id : "" , type : "cesium_ion" } ] } ,
256+ undefined ,
257+ "my-token" ,
258+ ) ,
259+ ) . toBe ( false ) ;
260+ } ) ;
261+
262+ test ( "returns false for cesium_ion tile with assetId of 0" , ( ) => {
263+ expect (
264+ computeHasCesiumIonAsset (
265+ { tiles : [ { id : "" , type : "cesium_ion" , cesiumIonAssetId : 0 } ] } ,
266+ undefined ,
267+ "my-token" ,
268+ ) ,
269+ ) . toBe ( false ) ;
270+ } ) ;
271+
272+ test ( "returns false for cesium_ion_default when no token" , ( ) => {
273+ expect (
274+ computeHasCesiumIonAsset ( {
275+ tiles : [ { id : "" , type : "cesium_ion_default" } ] ,
276+ } ) ,
277+ ) . toBe ( false ) ;
278+ } ) ;
279+
280+ test ( "returns false for legacy tile types when no token" , ( ) => {
281+ for ( const type of [ "default" , "default_road" , "default_label" , "black_marble" ] ) {
282+ expect ( computeHasCesiumIonAsset ( { tiles : [ { id : "" , type } ] } ) ) . toBe ( false ) ;
283+ }
284+ } ) ;
285+
286+ test ( "returns true for cesium_ion with valid assetId (token gate is at engine level)" , ( ) => {
287+ expect (
288+ computeHasCesiumIonAsset ( {
289+ tiles : [ { id : "" , type : "cesium_ion" , cesiumIonAssetId : 2275207 } ] ,
290+ } ) ,
291+ ) . toBe ( true ) ;
292+ } ) ;
293+ } ) ;
245294} ) ;
0 commit comments