diff options
author | 2023-08-03 17:44:18 -0700 | |
---|---|---|
committer | 2023-08-03 17:44:18 -0700 | |
commit | d10860d272fa266c9c064c4e75219af6a2b8bb73 (patch) | |
tree | 9ba02b60aa9ddb6e6c0bcb8a2a5dace615d7f9aa | |
parent | 76fa3076cd4f9bccf7eb0c48418957094114eca9 (diff) | |
download | bun-d10860d272fa266c9c064c4e75219af6a2b8bb73.tar.gz bun-d10860d272fa266c9c064c4e75219af6a2b8bb73.tar.zst bun-d10860d272fa266c9c064c4e75219af6a2b8bb73.zip |
Add type tests
-rw-r--r-- | packages/bun-types/tests/broadcast.test-d.ts | 11 | ||||
-rw-r--r-- | packages/bun-types/tests/diag.test-d.ts | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/packages/bun-types/tests/broadcast.test-d.ts b/packages/bun-types/tests/broadcast.test-d.ts new file mode 100644 index 000000000..ea5f8cb05 --- /dev/null +++ b/packages/bun-types/tests/broadcast.test-d.ts @@ -0,0 +1,11 @@ +const channel = new BroadcastChannel("my-channel"); +const message = { hello: "world" }; + +channel.onmessage = event => { + console.log(event.data); // { hello: "world" } +}; +channel.postMessage(message); + +const error = new Error("hello world"); +const clone = structuredClone(error); +console.log(clone.message); // "hello world" diff --git a/packages/bun-types/tests/diag.test-d.ts b/packages/bun-types/tests/diag.test-d.ts new file mode 100644 index 000000000..35f41ce05 --- /dev/null +++ b/packages/bun-types/tests/diag.test-d.ts @@ -0,0 +1,12 @@ +import diagnostics_channel from "diagnostics_channel"; + +// Create a channel object +const channel = diagnostics_channel.channel("my-channel"); + +// Subscribe to the channel +channel.subscribe((message, name) => { + console.log("Received message:", message); +}); + +// Publish a message to the channel +channel.publish({ some: "data" }); |