Skip to content

Commit 00b8fcd

Browse files
committed
Cleanup. Bump version.
1 parent b354913 commit 00b8fcd

File tree

11 files changed

+54
-101
lines changed

11 files changed

+54
-101
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,5 @@ dist
129129
.yarn/install-state.gz
130130
.pnp.*
131131

132-
.npmrc
132+
.npmrc
133+
.deno.lock

deno.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "@cross/test",
3-
"version": "0.0.4",
4-
"exports": "./mod.js",
3+
"version": "0.0.5",
4+
"exports": "./mod.ts",
55
"fmt": {
66
"lineWidth": 200
77
},
8-
"imports": { "@cross/test": "jsr:@cross/test@^0.0.2", "@std/assert": "jsr:@std/assert@^0.218.2" }
8+
"imports": {
9+
"@cross/runtime": "jsr:@cross/runtime@^0.0.10",
10+
"@std/assert": "jsr:@std/assert@^0.218.2"
11+
}
912
}

deno.lock

Lines changed: 6 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mod.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

mod.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test } from "./mod.js";
1+
import { test } from "./mod.ts";
22
import { assertEquals, assertNotEquals } from "@std/assert";
33

44
test("Addition", {}, () => {

mod.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { CurrentRuntime, Runtime } from "@cross/runtime";
2+
3+
/**
4+
* Runtime independent test function
5+
*/
6+
export interface WrappedTest {
7+
(name: string, options: WrappedTestOptions, testFn: () => Promise<void>): Promise<void>;
8+
}
9+
10+
/**
11+
* Runtime independent test options
12+
*/
13+
export interface WrappedTestOptions {
14+
timeout?: number; // Timeout duration in milliseconds (optional)
15+
skip?: boolean; // Whether to skip the test (optional)
16+
}
17+
18+
let wrappedTestToUse: WrappedTest | undefined;
19+
if (CurrentRuntime == Runtime.Deno) {
20+
const { wrappedTest } = await import("./shims/deno.js");
21+
// @ts-ignore js
22+
wrappedTestToUse = wrappedTest;
23+
} else if (CurrentRuntime == Runtime.Node) {
24+
const { wrappedTest } = await import("./shims/node.js");
25+
// @ts-ignore js
26+
wrappedTestToUse = wrappedTest;
27+
} else {
28+
throw new Error("Unsupported runtime");
29+
}
30+
/**
31+
* Defines and executes a single test.
32+
* @param {string} name - The name of the test.
33+
* @param {any} options - Options for the test (structure depends on your shim)
34+
* @param {() => Promise<void>} testFn - The function containing the test logic.
35+
*/
36+
export async function test(name: string, options: WrappedTestOptions, testFn: () => Promise<void>) {
37+
if (wrappedTestToUse) await wrappedTestToUse(name, options, testFn);
38+
}

package-lock.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

runtime.js

Lines changed: 0 additions & 27 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)