forked from sindresorhus/get-windows
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.test-d.ts
35 lines (30 loc) · 1.09 KB
/
index.test-d.ts
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
import {expectType, expectError} from 'tsd';
import activeWin = require('.');
import {Result, LinuxResult, MacOSResult, WindowsResult} from '.';
expectType<Promise<Result | undefined>>(activeWin());
const result = activeWin.sync();
expectType<Result | undefined>(result);
if (result) {
expectType<'macos' | 'linux' | 'windows'>(result.platform);
expectType<string>(result.title);
expectType<number>(result.id);
expectType<number>(result.bounds.x);
expectType<number>(result.bounds.y);
expectType<number>(result.bounds.width);
expectType<number>(result.bounds.height);
expectType<string>(result.owner.name);
expectType<number>(result.owner.processId);
expectType<string>(result.owner.path);
expectType<number>(result.memoryUsage);
if (result.platform === 'macos') {
expectType<MacOSResult>(result);
expectType<number>(result.owner.bundleId);
expectType<string | undefined>(result.url);
} else if (result.platform === 'linux') {
expectType<LinuxResult>(result);
expectError(result.owner.bundleId);
} else {
expectType<WindowsResult>(result);
expectError(result.owner.bundleId);
}
}