diff options
author | 2023-03-07 12:22:34 -0800 | |
---|---|---|
committer | 2023-03-07 12:22:34 -0800 | |
commit | f7e4eb83694aa007a492ef66c28ffbe6a2dae791 (patch) | |
tree | 7af25aa5c42a2e1b2b47ba1df35f8caa9054cbeb /test/bun.js/peek.test.ts | |
parent | 36275a44ce7a33587bd26aad120042ab95470ff3 (diff) | |
download | bun-f7e4eb83694aa007a492ef66c28ffbe6a2dae791.tar.gz bun-f7e4eb83694aa007a492ef66c28ffbe6a2dae791.tar.zst bun-f7e4eb83694aa007a492ef66c28ffbe6a2dae791.zip |
Reorganize tests (#2332)
Diffstat (limited to 'test/bun.js/peek.test.ts')
-rw-r--r-- | test/bun.js/peek.test.ts | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/test/bun.js/peek.test.ts b/test/bun.js/peek.test.ts deleted file mode 100644 index 421c306d8..000000000 --- a/test/bun.js/peek.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { peek } from "bun"; -import { expect, test } from "bun:test"; - -test("peek", () => { - const promise = Promise.resolve(true); - - // no await necessary! - expect(peek(promise)).toBe(true); - - // if we peek again, it returns the same value - const again = peek(promise); - expect(again).toBe(true); - - // if we peek a non-promise, it returns the value - const value = peek(42); - expect(value).toBe(42); - - // if we peek a pending promise, it returns the promise again - const pending = new Promise(() => {}); - expect(peek(pending)).toBe(pending); - - // If we peek a rejected promise, it: - // - returns the error - // - does not mark the promise as handled - const rejected = Promise.reject<Error>(new Error("Succesfully tested promise rejection")); - const peeked = peek(rejected); - expect(peeked instanceof Error).toBe(true); - expect((peeked as Error).message).toBe("Succesfully tested promise rejection"); - rejected.catch(() => {}); -}); - -test("peek.status", () => { - const promise = Promise.resolve(true); - expect(peek.status(promise)).toBe("fulfilled"); - - const pending = new Promise(() => {}); - expect(peek.status(pending)).toBe("pending"); - - const rejected = Promise.reject(new Error("oh nooo")); - expect(peek.status(rejected)).toBe("rejected"); - rejected.catch(() => {}); -}); |