-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathisExtractableFile.test.mjs
48 lines (38 loc) · 1.15 KB
/
isExtractableFile.test.mjs
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
// @ts-check
import { strictEqual } from "node:assert";
import revertableGlobals from "revertable-globals";
import isExtractableFile from "./isExtractableFile.mjs";
import assertBundleSize from "./test/assertBundleSize.mjs";
/**
* Adds `isExtractableFile` tests.
* @param {import("test-director").default} tests Test director.
*/
export default (tests) => {
tests.add("`isExtractableFile` bundle size.", async () => {
await assertBundleSize(
new URL("./isExtractableFile.mjs", import.meta.url),
120
);
});
tests.add("`isExtractableFile` with a `File` instance.", () => {
class File {}
const revertGlobals = revertableGlobals({ File });
try {
strictEqual(isExtractableFile(new File()), true);
} finally {
revertGlobals();
}
});
tests.add("`isExtractableFile` with a `Blob` instance.", () => {
class Blob {}
const revertGlobals = revertableGlobals({ Blob });
try {
strictEqual(isExtractableFile(new Blob()), true);
} finally {
revertGlobals();
}
});
tests.add("`isExtractableFile` with a non-file.", () => {
strictEqual(isExtractableFile({}), false);
});
};