|
| 1 | +import { describe, expect, it } from 'vitest'; |
| 2 | +import { PLATFORMS, PLATFORM_CONFIGS, getPlatforms, getPlatformConfig } from '../../config/platforms.js'; |
| 3 | +import type { Platform, PlatformConfig } from '../../config/platforms.js'; |
| 4 | + |
| 5 | +describe('PLATFORMS', () => { |
| 6 | + it('includes angular, react, and webcomponents', () => { |
| 7 | + expect(PLATFORMS).toContain('angular'); |
| 8 | + expect(PLATFORMS).toContain('react'); |
| 9 | + expect(PLATFORMS).toContain('webcomponents'); |
| 10 | + }); |
| 11 | + |
| 12 | + it('has exactly 3 entries', () => { |
| 13 | + expect(PLATFORMS).toHaveLength(3); |
| 14 | + }); |
| 15 | +}); |
| 16 | + |
| 17 | +describe('PLATFORM_CONFIGS', () => { |
| 18 | + it('has a config for every platform', () => { |
| 19 | + for (const platform of PLATFORMS) { |
| 20 | + expect(PLATFORM_CONFIGS[platform]).toBeDefined(); |
| 21 | + expect(PLATFORM_CONFIGS[platform].key).toBe(platform); |
| 22 | + } |
| 23 | + }); |
| 24 | + |
| 25 | + it('angular uses markdown-index api source', () => { |
| 26 | + expect(PLATFORM_CONFIGS.angular.apiSource.kind).toBe('markdown-index'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('react uses typedoc-json api source with a jsonPath', () => { |
| 30 | + const source = PLATFORM_CONFIGS.react.apiSource; |
| 31 | + expect(source.kind).toBe('typedoc-json'); |
| 32 | + if (source.kind === 'typedoc-json') { |
| 33 | + expect(source.jsonPath).toBeDefined(); |
| 34 | + expect(source.jsonPath).toContain('.json'); |
| 35 | + } |
| 36 | + }); |
| 37 | + |
| 38 | + it('webcomponents uses markdown-index api source', () => { |
| 39 | + expect(PLATFORM_CONFIGS.webcomponents.apiSource.kind).toBe('markdown-index'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('each config has required fields', () => { |
| 43 | + for (const platform of PLATFORMS) { |
| 44 | + const config = PLATFORM_CONFIGS[platform]; |
| 45 | + expect(config.displayName).toBeTruthy(); |
| 46 | + expect(config.submodulePath).toBeTruthy(); |
| 47 | + expect(config.docsPath).toBeTruthy(); |
| 48 | + } |
| 49 | + }); |
| 50 | +}); |
| 51 | + |
| 52 | +describe('getPlatforms()', () => { |
| 53 | + it('returns an array of PlatformConfig objects', () => { |
| 54 | + const platforms = getPlatforms(); |
| 55 | + expect(platforms).toBeInstanceOf(Array); |
| 56 | + expect(platforms.length).toBeGreaterThan(0); |
| 57 | + }); |
| 58 | + |
| 59 | + it('returns one config per platform', () => { |
| 60 | + const platforms = getPlatforms(); |
| 61 | + expect(platforms).toHaveLength(PLATFORMS.length); |
| 62 | + }); |
| 63 | + |
| 64 | + it('each returned config has a key matching a PLATFORMS entry', () => { |
| 65 | + const keys = getPlatforms().map(p => p.key); |
| 66 | + for (const platform of PLATFORMS) { |
| 67 | + expect(keys).toContain(platform); |
| 68 | + } |
| 69 | + }); |
| 70 | +}); |
| 71 | + |
| 72 | +describe('getPlatformConfig()', () => { |
| 73 | + it('returns the correct config for angular', () => { |
| 74 | + const config = getPlatformConfig('angular'); |
| 75 | + expect(config.key).toBe('angular'); |
| 76 | + expect(config.displayName).toBe('Angular'); |
| 77 | + }); |
| 78 | + |
| 79 | + it('returns the correct config for react', () => { |
| 80 | + const config = getPlatformConfig('react'); |
| 81 | + expect(config.key).toBe('react'); |
| 82 | + expect(config.displayName).toBe('React'); |
| 83 | + }); |
| 84 | + |
| 85 | + it('returns the correct config for webcomponents', () => { |
| 86 | + const config = getPlatformConfig('webcomponents'); |
| 87 | + expect(config.key).toBe('webcomponents'); |
| 88 | + expect(config.displayName).toBe('Web Components'); |
| 89 | + }); |
| 90 | +}); |
0 commit comments