diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/apps/bun-dev-index-html.sh | 2 | ||||
| -rw-r--r-- | test/apps/bun-dev.sh | 2 | ||||
| -rw-r--r-- | test/apps/bun-install-lockfile-status.sh | 2 | ||||
| -rw-r--r-- | test/apps/bun-install-utf8.sh | 2 | ||||
| -rw-r--r-- | test/apps/bun-install.sh | 2 | ||||
| l--------- | test/bun.js/fs-stream.link.js | 1 | ||||
| -rw-r--r-- | test/bun.js/fs.test.js | 61 | ||||
| -rw-r--r-- | test/bun.js/snapshots.debug.js | 10 | ||||
| -rw-r--r-- | test/bun.js/snapshots.js | 10 |
9 files changed, 87 insertions, 5 deletions
diff --git a/test/apps/bun-dev-index-html.sh b/test/apps/bun-dev-index-html.sh index 14db88113..f22f8df51 100644 --- a/test/apps/bun-dev-index-html.sh +++ b/test/apps/bun-dev-index-html.sh @@ -4,7 +4,7 @@ set -euo pipefail killall -9 $(basename $BUN_BIN) || echo "" -dir=$(mktemp -d --suffix=bun-dev-check) +dir=$(mktemp -d) index_content="<html><body>index.html</body></html>" bacon_content="<html><body>bacon.html</body></html>" diff --git a/test/apps/bun-dev.sh b/test/apps/bun-dev.sh index 76db4c71d..ea15c1d21 100644 --- a/test/apps/bun-dev.sh +++ b/test/apps/bun-dev.sh @@ -4,7 +4,7 @@ set -euo pipefail killall -9 $(basename $BUN_BIN) || echo "" -dir=$(mktemp -d --suffix=bun-dev-check) +dir=$(mktemp -d) index_content="<html><body>index.html</body></html>" bacon_content="<html><body>bacon.html</body></html>" diff --git a/test/apps/bun-install-lockfile-status.sh b/test/apps/bun-install-lockfile-status.sh index 96b39a09e..fc39a6dd6 100644 --- a/test/apps/bun-install-lockfile-status.sh +++ b/test/apps/bun-install-lockfile-status.sh @@ -4,7 +4,7 @@ set -euo pipefail killall -9 $(basename $BUN_BIN) || echo "" -dir=$(mktemp -d --suffix=bun-lockfile) +dir=$(mktemp -d) cd $dir diff --git a/test/apps/bun-install-utf8.sh b/test/apps/bun-install-utf8.sh index 28e644708..14976bac7 100644 --- a/test/apps/bun-install-utf8.sh +++ b/test/apps/bun-install-utf8.sh @@ -4,7 +4,7 @@ set -euo pipefail killall -9 $(basename $BUN_BIN) || echo "" -dir=$(mktemp -d --suffix=bun-ADD) +dir=$(mktemp -d) cd $dir diff --git a/test/apps/bun-install.sh b/test/apps/bun-install.sh index 6ca07c20f..af13f6fc3 100644 --- a/test/apps/bun-install.sh +++ b/test/apps/bun-install.sh @@ -2,7 +2,7 @@ set -euo pipefail -dir=$(mktemp -d --suffix=bun-install-test-1) +dir=$(mktemp -d) cd $dir ${NPM_CLIENT:-$(which bun)} add react react-dom @types/react @babel/parser esbuild diff --git a/test/bun.js/fs-stream.link.js b/test/bun.js/fs-stream.link.js new file mode 120000 index 000000000..0cadae0e5 --- /dev/null +++ b/test/bun.js/fs-stream.link.js @@ -0,0 +1 @@ +./test/bun.js/fs-stream.js
\ No newline at end of file diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.js index 79ac60eaa..d3c6be901 100644 --- a/test/bun.js/fs.test.js +++ b/test/bun.js/fs.test.js @@ -11,6 +11,8 @@ import { readSync, writeFileSync, writeSync, + statSync, + lstatSync, } from "node:fs"; const Buffer = globalThis.Buffer || Uint8Array; @@ -242,3 +244,62 @@ describe("writeFileSync", () => { } }); }); + +describe("lstat", () => { + it("file metadata is correct", () => { + const fileStats = lstatSync( + new URL("./fs-stream.js", import.meta.url) + .toString() + .slice("file://".length - 1) + ); + expect(fileStats.isSymbolicLink()).toBe(false); + expect(fileStats.isFile()).toBe(true); + expect(fileStats.isDirectory()).toBe(false); + }); + + it("folder metadata is correct", () => { + const fileStats = lstatSync( + new URL("../../test", import.meta.url) + .toString() + .slice("file://".length - 1) + ); + expect(fileStats.isSymbolicLink()).toBe(false); + expect(fileStats.isFile()).toBe(false); + expect(fileStats.isDirectory()).toBe(true); + }); + + it("symlink metadata is correct", () => { + const linkStats = lstatSync( + new URL("./fs-stream.link.js", import.meta.url) + .toString() + .slice("file://".length - 1) + ); + expect(linkStats.isSymbolicLink()).toBe(true); + expect(linkStats.isFile()).toBe(false); + expect(linkStats.isDirectory()).toBe(false); + }); +}); + +describe("stat", () => { + it("file metadata is correct", () => { + const fileStats = statSync( + new URL("./fs-stream.js", import.meta.url) + .toString() + .slice("file://".length - 1) + ); + expect(fileStats.isSymbolicLink()).toBe(false); + expect(fileStats.isFile()).toBe(true); + expect(fileStats.isDirectory()).toBe(false); + }); + + it("folder metadata is correct", () => { + const fileStats = statSync( + new URL("../../test", import.meta.url) + .toString() + .slice("file://".length - 1) + ); + expect(fileStats.isSymbolicLink()).toBe(false); + expect(fileStats.isFile()).toBe(false); + expect(fileStats.isDirectory()).toBe(true); + }); +}); diff --git a/test/bun.js/snapshots.debug.js b/test/bun.js/snapshots.debug.js new file mode 100644 index 000000000..d4c345677 --- /dev/null +++ b/test/bun.js/snapshots.debug.js @@ -0,0 +1,10 @@ + +// test/bun.js/module-require.snapshot.js +import { +__require as require +} from "bun:wrap"; +console.log(import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js")); + +// test/bun.js/require-referenceerror.snapshot.js + +// test/bun.js/tiny-typed-emitter.snapshot.js diff --git a/test/bun.js/snapshots.js b/test/bun.js/snapshots.js new file mode 100644 index 000000000..d4c345677 --- /dev/null +++ b/test/bun.js/snapshots.js @@ -0,0 +1,10 @@ + +// test/bun.js/module-require.snapshot.js +import { +__require as require +} from "bun:wrap"; +console.log(import.meta.require("/Users/jarred/Code/bun/node_modules/react/index.js")); + +// test/bun.js/require-referenceerror.snapshot.js + +// test/bun.js/tiny-typed-emitter.snapshot.js |
