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