|
1 | 1 | import { Tinytest } from "meteor/tinytest"; |
2 | 2 |
|
3 | 3 | // Type compilation tests for meteor/tools |
4 | | -// These tests verify that TypeScript types are correctly defined. |
5 | | -// If this file compiles without errors, the types are correct. |
6 | 4 |
|
7 | | -// Import types to verify they exist |
8 | | -import type { Assets, Npm, Package, App, Cordova, PackageAPI } from "meteor/tools"; |
9 | | - |
10 | | -// ============================================================================ |
11 | | -// Assets type tests (runtime global) |
12 | | -// ============================================================================ |
13 | | - |
14 | | -Tinytest.add("tools types - Assets.getTextAsync returns Promise<string>", (test) => { |
15 | | - // Type assertion: getTextAsync should return Promise<string> |
16 | | - const getTextAsync: Assets["getTextAsync"] = Assets.getTextAsync; |
17 | | - test.isTrue(typeof getTextAsync === "function", "Assets.getTextAsync should be a function"); |
| 5 | +Tinytest.add("tools types - Assets.getTextAsync is a function", (test) => { |
| 6 | + test.isTrue( |
| 7 | + typeof Assets.getTextAsync === "function", |
| 8 | + "Assets.getTextAsync should be a function" |
| 9 | + ); |
18 | 10 | }); |
19 | 11 |
|
20 | | -Tinytest.add("tools types - Assets.getBinaryAsync returns Promise<Uint8Array>", (test) => { |
21 | | - // Type assertion: getBinaryAsync should return Promise<Uint8Array> |
22 | | - const getBinaryAsync: Assets["getBinaryAsync"] = Assets.getBinaryAsync; |
23 | | - test.isTrue(typeof getBinaryAsync === "function", "Assets.getBinaryAsync should be a function"); |
| 12 | +Tinytest.add("tools types - Assets.getBinaryAsync is a function", (test) => { |
| 13 | + test.isTrue( |
| 14 | + typeof Assets.getBinaryAsync === "function", |
| 15 | + "Assets.getBinaryAsync should be a function" |
| 16 | + ); |
24 | 17 | }); |
25 | 18 |
|
26 | 19 | Tinytest.add("tools types - Assets.absoluteFilePath returns string", (test) => { |
27 | 20 | const result = Assets.absoluteFilePath("test.txt"); |
28 | | - test.isTrue(typeof result === "string", "Assets.absoluteFilePath should return a string"); |
| 21 | + test.isTrue( |
| 22 | + typeof result === "string", |
| 23 | + "Assets.absoluteFilePath should return a string" |
| 24 | + ); |
29 | 25 | }); |
30 | 26 |
|
31 | 27 | Tinytest.add("tools types - Assets.getServerDir returns string", (test) => { |
32 | 28 | const result = Assets.getServerDir(); |
33 | | - test.isTrue(typeof result === "string", "Assets.getServerDir should return a string"); |
| 29 | + test.isTrue( |
| 30 | + typeof result === "string", |
| 31 | + "Assets.getServerDir should return a string" |
| 32 | + ); |
34 | 33 | }); |
35 | | - |
36 | | -// ============================================================================ |
37 | | -// Type-level tests (compilation only, no runtime execution) |
38 | | -// These are compile-time assertions that verify type correctness. |
39 | | -// ============================================================================ |
40 | | - |
41 | | -// Test that PackageAPI interface has expected methods |
42 | | -type TestPackageAPI = { |
43 | | - versionsFrom: PackageAPI["versionsFrom"]; |
44 | | - use: PackageAPI["use"]; |
45 | | - imply: PackageAPI["imply"]; |
46 | | - export: PackageAPI["export"]; |
47 | | - addFiles: PackageAPI["addFiles"]; |
48 | | - addAssets: PackageAPI["addAssets"]; |
49 | | - mainModule: PackageAPI["mainModule"]; |
50 | | -}; |
51 | | - |
52 | | -// Type-level assertion: this will fail to compile if PackageAPI is missing methods |
53 | | -const _typeTest: TestPackageAPI = {} as PackageAPI; |
54 | | - |
55 | | -// Verify global declarations work with interface types |
56 | | -declare const _assetsGlobal: Assets; |
57 | | -declare const _npmGlobal: Npm; |
58 | | -declare const _packageGlobal: Package; |
59 | | -declare const _appGlobal: App; |
60 | | -declare const _cordovaGlobal: Cordova; |
0 commit comments