-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.test-d.ts
41 lines (38 loc) · 1.51 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
36
37
38
39
40
41
import process from 'node:process';
import {Buffer} from 'node:buffer';
import {expectType, expectError} from 'tsd';
import {
temporaryFile,
temporaryFileTask,
temporaryDirectory,
temporaryDirectoryTask,
temporaryWrite,
temporaryWriteTask,
temporaryWriteSync,
rootTemporaryDirectory,
type FileOptions,
} from './index.js';
const options: FileOptions = {};
expectType<string>(temporaryDirectory());
expectType<string>(temporaryDirectory({prefix: 'name_'}));
expectType<string>(temporaryFile());
expectType<Promise<void>>(temporaryFileTask(temporaryFile => {
expectType<string>(temporaryFile);
}));
expectType<Promise<void>>(temporaryDirectoryTask(temporaryDirectory => {
expectType<string>(temporaryDirectory);
}));
expectType<string>(temporaryFile({extension: 'png'}));
expectType<string>(temporaryFile({name: 'afile.txt'}));
expectError(temporaryFile({extension: 'png', name: 'afile.txt'}));
expectType<string>(rootTemporaryDirectory);
expectType<Promise<string>>(temporaryWrite('unicorn'));
expectType<Promise<string>>(temporaryWrite('unicorn', {name: 'pony.png'}));
expectType<Promise<string>>(temporaryWrite(process.stdin, {name: 'pony.png'}));
expectType<Promise<string>>(temporaryWrite(Buffer.from('pony'), {name: 'pony.png'}));
expectType<Promise<void>>(temporaryWriteTask('', temporaryFile => {
expectType<string>(temporaryFile);
}));
expectType<string>(temporaryWriteSync('unicorn'));
expectType<string>(temporaryWriteSync(Buffer.from('unicorn')));
expectType<string>(temporaryWriteSync('unicorn', {name: 'pony.png'}));