forked from JhaSourav07/commitpulse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.type-compiler.test.ts
More file actions
60 lines (52 loc) · 1.92 KB
/
Copy pathtypes.type-compiler.test.ts
File metadata and controls
60 lines (52 loc) · 1.92 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
import { describe, it, expectTypeOf } from 'vitest';
import type {
BadgeSize,
CustomizeOptions,
DeltaFormat,
ExportFormat,
Font,
Language,
Scale,
ThemeOption,
Timezone,
ViewMode,
} from './types';
describe('types - compiler validation', () => {
it('accepts valid literal types', () => {
expectTypeOf<Scale>().toMatchTypeOf<'linear' | 'log' | 'sqrt'>();
expectTypeOf<ExportFormat>().toMatchTypeOf<'markdown' | 'html' | 'action' | 'tsx'>();
expectTypeOf<BadgeSize>().toMatchTypeOf<'small' | 'medium' | 'large'>();
});
it('validates CustomizeOptions structure', () => {
expectTypeOf<CustomizeOptions>().toHaveProperty('username');
expectTypeOf<CustomizeOptions>().toHaveProperty('theme');
expectTypeOf<CustomizeOptions>().toHaveProperty('scale');
expectTypeOf<CustomizeOptions>().toHaveProperty('viewMode');
expectTypeOf<CustomizeOptions>().toHaveProperty('timezone');
});
it('accepts supported string-based option types', () => {
expectTypeOf<Font>().toMatchTypeOf<string>();
expectTypeOf<ThemeOption>().toMatchTypeOf<string>();
});
it('validates constrained union types', () => {
expectTypeOf<ViewMode>().toMatchTypeOf<
'default' | 'monthly' | 'pulse' | 'skyline' | 'languages' | 'punchcard'
>();
expectTypeOf<DeltaFormat>().toMatchTypeOf<'percent' | 'absolute' | 'both'>();
expectTypeOf<Language>().toMatchTypeOf<'en' | 'es' | 'hi' | 'pt' | 'ko' | 'fr' | 'ja' | 'de'>();
expectTypeOf<Timezone>().toMatchTypeOf<
| 'UTC'
| 'America/New_York'
| 'America/Los_Angeles'
| 'Europe/London'
| 'Europe/Berlin'
| 'Asia/Kolkata'
| 'Asia/Tokyo'
| 'Australia/Sydney'
>();
});
it('supports numeric and empty-string badge dimensions', () => {
expectTypeOf<CustomizeOptions['badgeWidth']>().toEqualTypeOf<number | ''>();
expectTypeOf<CustomizeOptions['badgeHeight']>().toEqualTypeOf<number | ''>();
});
});