From 65636697d33c22e5cdf1825e3f6387d227f0cab2 Mon Sep 17 00:00:00 2001 From: Ethan Dennis Date: Wed, 18 Mar 2020 17:49:09 -0700 Subject: [PATCH] Use fs promises in actionUtils tests --- __tests__/actionUtils.test.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/__tests__/actionUtils.test.ts b/__tests__/actionUtils.test.ts index 79801f0..d1beb3a 100644 --- a/__tests__/actionUtils.test.ts +++ b/__tests__/actionUtils.test.ts @@ -343,13 +343,15 @@ test("isValidEvent returns true for pull request event", () => { }); test("unlinkFile unlinks file", async () => { - const testDirectory = fs.mkdtempSync("unlinkFileTest"); + const testDirectory = await fs.mkdtemp("unlinkFileTest"); const testFile = path.join(testDirectory, "test.txt"); - fs.writeFileSync(testFile, "hello world"); + await fs.writeFile(testFile, "hello world"); await actionUtils.unlinkFile(testFile); - expect(fs.existsSync(testFile)).toBe(false); + await expect(fs.stat(testFile)).rejects.toThrow( + `ENOENT: no such file or directory, stat '${testFile}'` + ); - fs.rmdirSync(testDirectory); + await fs.rmdir(testDirectory); });