|
| 1 | +import { describe, expect, test } from 'vitest'; |
| 2 | +import { documentation, properties, resources } from '../../src/presentation-4/meta'; |
| 3 | + |
| 4 | +describe('presentation-4 meta generation', () => { |
| 5 | + test('contains required class anchors', () => { |
| 6 | + const requiredClasses = [ |
| 7 | + 'Collection', |
| 8 | + 'Manifest', |
| 9 | + 'Timeline', |
| 10 | + 'Canvas', |
| 11 | + 'Scene', |
| 12 | + 'Annotation', |
| 13 | + 'AnnotationPage', |
| 14 | + 'AnnotationCollection', |
| 15 | + 'SpecificResource', |
| 16 | + 'Range', |
| 17 | + 'Agent', |
| 18 | + 'Service', |
| 19 | + 'Quantity', |
| 20 | + 'ImageApiSelector', |
| 21 | + 'PointSelector', |
| 22 | + ] as const; |
| 23 | + |
| 24 | + for (const className of requiredClasses) { |
| 25 | + const def = documentation.definedTypes[className]; |
| 26 | + expect(def, `missing class ${className}`).toBeDefined(); |
| 27 | + if (!def) { |
| 28 | + continue; |
| 29 | + } |
| 30 | + expect(def.link).toBe(`${documentation.root}#${className}`); |
| 31 | + expect(def.summary.length).toBeGreaterThan(0); |
| 32 | + } |
| 33 | + }); |
| 34 | + |
| 35 | + test('contains required property anchors', () => { |
| 36 | + const requiredProperties = [ |
| 37 | + 'id', |
| 38 | + 'type', |
| 39 | + 'label', |
| 40 | + 'items', |
| 41 | + 'annotations', |
| 42 | + 'metadata', |
| 43 | + 'summary', |
| 44 | + 'requiredStatement', |
| 45 | + 'rights', |
| 46 | + 'provider', |
| 47 | + 'thumbnail', |
| 48 | + 'start', |
| 49 | + 'structures', |
| 50 | + 'behavior', |
| 51 | + 'viewingDirection', |
| 52 | + 'timeMode', |
| 53 | + 'body', |
| 54 | + 'target', |
| 55 | + 'selector', |
| 56 | + 'source', |
| 57 | + 'service', |
| 58 | + 'services', |
| 59 | + ] as const; |
| 60 | + |
| 61 | + for (const property of requiredProperties) { |
| 62 | + const def = documentation.properties[property]; |
| 63 | + expect(def, `missing property ${property}`).toBeDefined(); |
| 64 | + if (!def) { |
| 65 | + continue; |
| 66 | + } |
| 67 | + expect(def.link).toBe(`${documentation.root}#${property}`); |
| 68 | + expect(def.summary.length).toBeGreaterThan(0); |
| 69 | + } |
| 70 | + }); |
| 71 | + |
| 72 | + test('resource groups and property categories are deterministic', () => { |
| 73 | + const sortedResources = [...resources.all].sort((a, b) => a.localeCompare(b)); |
| 74 | + expect(resources.all).toEqual(sortedResources); |
| 75 | + |
| 76 | + const allGroupedResources = Object.values(resources.groups).flat(); |
| 77 | + expect(new Set(allGroupedResources).size).toBe(resources.all.length); |
| 78 | + |
| 79 | + const sortedProperties = [...properties.all].sort((a, b) => a.localeCompare(b)); |
| 80 | + expect(properties.all).toEqual(sortedProperties); |
| 81 | + |
| 82 | + const allCategorizedProperties = Object.values(properties.categories).flat(); |
| 83 | + expect(new Set(allCategorizedProperties).size).toBe(properties.all.length); |
| 84 | + }); |
| 85 | +}); |
0 commit comments