Skip to content

Commit 44e22df

Browse files
author
John Doe
committed
refactor: add type tests
1 parent 1fa6d3d commit 44e22df

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { describe, expectTypeOf, it } from 'vitest';
2+
import type {
3+
DevToolsColor,
4+
MarkerPayload,
5+
TrackEntryPayload,
6+
WithDevToolsPayload,
7+
WithErrorColor,
8+
} from './user-timing-extensibility-api.type.js';
9+
10+
describe('TrackEntryPayload', () => {
11+
it('TrackEntryPayload extends ExtensionTrackBase and TrackMeta', () => {
12+
expectTypeOf<{
13+
dataType?: 'track-entry';
14+
track: string;
15+
}>().toMatchTypeOf<TrackEntryPayload>();
16+
});
17+
});
18+
19+
describe('MarkerPayload', () => {
20+
it('MarkerPayload extends ExtensionTrackBase with required dataType', () => {
21+
expectTypeOf<{
22+
dataType: 'marker';
23+
}>().toMatchTypeOf<MarkerPayload>();
24+
});
25+
});
26+
27+
describe('WithErrorColor', () => {
28+
it('WithErrorColor removes optional color and adds required error color', () => {
29+
expectTypeOf<{
30+
color: 'error';
31+
otherProp: string;
32+
}>().toMatchTypeOf<
33+
WithErrorColor<{ color?: DevToolsColor; otherProp: string }>
34+
>();
35+
});
36+
});
37+
38+
describe('WithDevToolsPayload', () => {
39+
it('WithDevToolsPayload makes devtools optional', () => {
40+
expectTypeOf<{
41+
devtools?: TrackEntryPayload;
42+
}>().toMatchTypeOf<WithDevToolsPayload<TrackEntryPayload>>();
43+
});
44+
});

0 commit comments

Comments
 (0)