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.16 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 activeWindow = require('./index.js');
import {Result, LinuxResult, MacOSResult, WindowsResult, BaseOwner} from './index.js';
expectType<Promise<Result | undefined>>(activeWindow());
const result = activeWindow.sync({screenRecordingPermission: false});
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<string>(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);
}
}