mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
Make these tests do more
This commit is contained in:
@@ -1,8 +1,20 @@
|
||||
import { test, expect } from "bun:test";
|
||||
|
||||
import { join } from "path";
|
||||
import { tmpdir } from "os";
|
||||
import { write } from "bun";
|
||||
import { unlinkSync } from "fs";
|
||||
test("bun-file-exists", async () => {
|
||||
expect(await Bun.file(import.meta.path).exists()).toBeTrue();
|
||||
expect(await Bun.file(import.meta.path + "boop").exists()).toBeFalse();
|
||||
expect(await Bun.file(import.meta.dir).exists()).toBeFalse();
|
||||
expect(await Bun.file(import.meta.dir + "/").exists()).toBeFalse();
|
||||
const temp = join(tmpdir(), "bun-file-exists.test.js");
|
||||
try {
|
||||
unlinkSync(temp);
|
||||
} catch (e) {}
|
||||
expect(await Bun.file(temp).exists()).toBeFalse();
|
||||
await write(temp, "boop");
|
||||
expect(await Bun.file(temp).exists()).toBeTrue();
|
||||
unlinkSync(temp);
|
||||
expect(await Bun.file(temp).exists()).toBeFalse();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user