From 086ca176be5c8dcc30278b97df274f152fcd112e Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Wed, 28 Jun 2023 16:19:58 -0700 Subject: [PATCH] Make these tests do more --- test/js/bun/util/bun-file-exists.test.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/js/bun/util/bun-file-exists.test.js b/test/js/bun/util/bun-file-exists.test.js index da6dce192f..cca28e3599 100644 --- a/test/js/bun/util/bun-file-exists.test.js +++ b/test/js/bun/util/bun-file-exists.test.js @@ -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(); });