Skip to content

Commit ab66e52

Browse files
committed
Fix 17 TS errors in test files - Geometry & validation types
Fixed geometry coordinate access and validation type issues: - Added geometry coordinate type assertions (6 fixes) - Added warnings property to ValidationResult interface (6 fixes) - Fixed time interval types (string arrays) (1 fix) - Fixed XLink type to object format (1 fix) - Fixed ValidationError to object format (1 fix) - Fixed Feature type cast (1 fix) - Fixed TimeComponent type cast (1 fix) Resolves Sam-Bolling/CSAPI-Live-Testing#78
1 parent 947388b commit ab66e52

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

src/ogc-api/csapi/parsers/parsers.edge-cases.spec.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('Parser Edge Cases', () => {
104104
properties: { featureType: 'System', uid: 'urn:test:1' }
105105
};
106106

107-
const result = parser.parseGeoJSON(feature);
107+
const result = parser.parseGeoJSON(feature as any);
108108
expect(result.geometry).toBeNull();
109109
});
110110

@@ -233,8 +233,8 @@ describe('Parser Edge Cases', () => {
233233
properties: { featureType: 'System', uid: 'urn:test:1' }
234234
};
235235

236-
const result = parser.parseGeoJSON(feature);
237-
expect(result.geometry?.coordinates?.[0]).toBe(Number.MAX_SAFE_INTEGER);
236+
const result = parser.parseGeoJSON(feature as any);
237+
expect((result.geometry as any)?.coordinates?.[0]).toBe(Number.MAX_SAFE_INTEGER);
238238
});
239239

240240
it('should handle negative zero', () => {
@@ -247,8 +247,8 @@ describe('Parser Edge Cases', () => {
247247
properties: { featureType: 'System', uid: 'urn:test:1' }
248248
};
249249

250-
const result = parser.parseGeoJSON(feature);
251-
expect(result.geometry?.coordinates?.[0]).toBe(-0);
250+
const result = parser.parseGeoJSON(feature as any);
251+
expect((result.geometry as any)?.coordinates?.[0]).toBe(-0);
252252
});
253253

254254
it('should handle very small numbers near MIN_VALUE', () => {
@@ -261,8 +261,8 @@ describe('Parser Edge Cases', () => {
261261
properties: { featureType: 'System', uid: 'urn:test:1' }
262262
};
263263

264-
const result = parser.parseGeoJSON(feature);
265-
expect(result.geometry?.coordinates?.[0]).toBe(Number.MIN_VALUE);
264+
const result = parser.parseGeoJSON(feature as any);
265+
expect((result.geometry as any)?.coordinates?.[0]).toBe(Number.MIN_VALUE);
266266
});
267267
});
268268

@@ -279,7 +279,7 @@ describe('Parser Edge Cases', () => {
279279
}
280280
};
281281

282-
const result = parser.parseGeoJSON(feature);
282+
const result = parser.parseGeoJSON(feature as any);
283283
expect(result.properties.description).toHaveLength(10 * 1024);
284284
});
285285

@@ -295,7 +295,7 @@ describe('Parser Edge Cases', () => {
295295
}
296296
};
297297

298-
const result = parser.parseGeoJSON(feature);
298+
const result = parser.parseGeoJSON(feature as any);
299299
expect(result.properties.name).toHaveLength(longName.length);
300300
});
301301
});
@@ -315,7 +315,7 @@ describe('Parser Edge Cases', () => {
315315
}
316316
};
317317

318-
const result = parser.parseGeoJSON(feature);
318+
const result = parser.parseGeoJSON(feature as any);
319319
expect(result.properties.name).toBe('温度传感器');
320320
expect(result.properties.uid).toContain('系统');
321321
});
@@ -332,7 +332,7 @@ describe('Parser Edge Cases', () => {
332332
}
333333
};
334334

335-
const result = parser.parseGeoJSON(feature);
335+
const result = parser.parseGeoJSON(feature as any);
336336
expect(result.properties.description).toContain('استشعار');
337337
});
338338

@@ -347,7 +347,7 @@ describe('Parser Edge Cases', () => {
347347
}
348348
};
349349

350-
const result = parser.parseGeoJSON(feature);
350+
const result = parser.parseGeoJSON(feature as any);
351351
expect(result.properties.name).toContain('🌡️');
352352
expect(result.properties.name).toContain('🔥');
353353
});
@@ -363,7 +363,7 @@ describe('Parser Edge Cases', () => {
363363
}
364364
};
365365

366-
const result = parser.parseGeoJSON(feature);
366+
const result = parser.parseGeoJSON(feature as any);
367367
expect(result.properties.name).toContain('טמפרטורה');
368368
});
369369

@@ -379,7 +379,7 @@ describe('Parser Edge Cases', () => {
379379
}
380380
};
381381

382-
const result = parser.parseGeoJSON(feature);
382+
const result = parser.parseGeoJSON(feature as any);
383383
expect(result.properties.name).toBe('温度センサー');
384384
expect(result.properties.description).toContain('センサー');
385385
});
@@ -396,7 +396,7 @@ describe('Parser Edge Cases', () => {
396396
}
397397
};
398398

399-
const result = parser.parseGeoJSON(feature);
399+
const result = parser.parseGeoJSON(feature as any);
400400
expect(result.properties.uid).toContain(' ');
401401
});
402402

@@ -410,7 +410,7 @@ describe('Parser Edge Cases', () => {
410410
}
411411
};
412412

413-
const result = parser.parseGeoJSON(feature);
413+
const result = parser.parseGeoJSON(feature as any);
414414
expect(result.properties.uid).toContain('@');
415415
expect(result.properties.uid).toContain('#');
416416
expect(result.properties.uid).toContain('!');
@@ -426,7 +426,7 @@ describe('Parser Edge Cases', () => {
426426
}
427427
};
428428

429-
const result = parser.parseGeoJSON(feature);
429+
const result = parser.parseGeoJSON(feature as any);
430430
expect(result.properties.uid).toContain('%20');
431431
});
432432
});
@@ -443,7 +443,7 @@ describe('Parser Edge Cases', () => {
443443
}
444444
};
445445

446-
const result = parser.parseGeoJSON(feature);
446+
const result = parser.parseGeoJSON(feature as any);
447447
expect(result.properties.name).toContain('Sensor');
448448
expect(result.properties.name).toContain('الحرارة');
449449
expect(result.properties.name).toContain('温度');
@@ -463,7 +463,7 @@ describe('Parser Edge Cases', () => {
463463
}
464464
};
465465

466-
const result = parser.parseGeoJSON(feature);
466+
const result = parser.parseGeoJSON(feature as any);
467467
expect(result.properties.name).toContain('\t');
468468
});
469469

@@ -478,7 +478,7 @@ describe('Parser Edge Cases', () => {
478478
}
479479
};
480480

481-
const result = parser.parseGeoJSON(feature);
481+
const result = parser.parseGeoJSON(feature as any);
482482
expect(result.properties.description).toContain('\n');
483483
});
484484

@@ -493,7 +493,7 @@ describe('Parser Edge Cases', () => {
493493
}
494494
};
495495

496-
const result = parser.parseGeoJSON(feature);
496+
const result = parser.parseGeoJSON(feature as any);
497497
expect(result.properties.name).toContain('\u00A0');
498498
});
499499
});
@@ -513,8 +513,8 @@ describe('Parser Edge Cases', () => {
513513
};
514514

515515
// Without validation, should pass through
516-
const result = parser.parseGeoJSON(feature);
517-
expect(result.geometry?.coordinates?.[1]).toBe(95.0);
516+
const result = parser.parseGeoJSON(feature as any);
517+
expect((result.geometry as any)?.coordinates?.[1]).toBe(95.0);
518518
});
519519

520520
it('should accept longitude > 180 without validation', () => {
@@ -528,8 +528,8 @@ describe('Parser Edge Cases', () => {
528528
};
529529

530530
// Without validation, should pass through
531-
const result = parser.parseGeoJSON(feature);
532-
expect(result.geometry?.coordinates?.[0]).toBe(190.0);
531+
const result = parser.parseGeoJSON(feature as any);
532+
expect((result.geometry as any)?.coordinates?.[0]).toBe(190.0);
533533
});
534534
});
535535

src/ogc-api/csapi/validation/constraint-validator.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,12 @@ describe('SWE Common Constraint Validation', () => {
348348
label: 'Time',
349349
uom: { code: 'ms' },
350350
constraint: {
351-
intervals: [[0, 1000000] as [number, number]],
351+
intervals: [['0', '1000000']],
352352
},
353353
value: 500000,
354354
};
355355

356-
const result = validateTimeConstraint(component, 500000);
356+
const result = validateTimeConstraint(component as any, 500000);
357357
expect(result.valid).toBe(true);
358358
});
359359

src/ogc-api/csapi/validation/geojson-validator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import type {
3030
export interface ValidationResult {
3131
valid: boolean;
3232
errors?: string[];
33+
warnings?: string[];
3334
}
3435

3536
/**

src/ogc-api/csapi/validation/sensorml-validator.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ describe('SensorML Validator', () => {
103103
},
104104
deployedSystems: [
105105
{
106-
system: 'urn:test:system-1',
106+
system: { href: 'urn:test:system-1' },
107107
},
108108
],
109109
};

src/ogc-api/csapi/validation/swe-validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export function validateSWEComponent(data: unknown, validateConstraints = true):
509509
export function validateObservationResult(data: unknown): ValidationResult {
510510
// Result can be any SWE Common component or simple value
511511
if (data === null || data === undefined) {
512-
return { valid: false, errors: ['Observation result cannot be null or undefined'] };
512+
return { valid: false, errors: [{ message: 'Observation result cannot be null or undefined' }] };
513513
}
514514

515515
// If it's an object with a type property, validate as SWE component

0 commit comments

Comments
 (0)