From 3a40916c7777a569b5a9e23fee4fa224fc776fde Mon Sep 17 00:00:00 2001 From: Takeshi Date: Fri, 16 Feb 2024 23:05:49 -0700 Subject: [PATCH] Improve tests --- src/utils/__test__/download.spec.ts | 9 +++++++-- src/utils/__test__/extract.spec.ts | 10 +++++----- src/utils/__test__/gitly.spec.ts | 12 ++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/utils/__test__/download.spec.ts b/src/utils/__test__/download.spec.ts index 4690be4..5df95b8 100644 --- a/src/utils/__test__/download.spec.ts +++ b/src/utils/__test__/download.spec.ts @@ -9,11 +9,16 @@ describe('utils/download (no cache)', () => { const options = { temp: join(__dirname, 'output', 'download'), } - beforeEach(async () => { + + beforeAll(() => { rm('-rf', join(__dirname, 'output', 'download')) }) - afterAll(async () => { + beforeEach(() => { + rm('-rf', join(__dirname, 'output', 'download')) + }) + + afterAll(() => { rm('-rf', join(__dirname, 'output', 'download')) }) diff --git a/src/utils/__test__/extract.spec.ts b/src/utils/__test__/extract.spec.ts index 8c4cee5..41ae095 100644 --- a/src/utils/__test__/extract.spec.ts +++ b/src/utils/__test__/extract.spec.ts @@ -6,20 +6,20 @@ import download from '../download' import extract from '../extract' describe('utils/extract', () => { - const destination = join(__dirname, 'output', 'extract', 'example') + const destination = join(__dirname, 'output', 'extract') const options = { temp: join(__dirname, 'output', 'extract', '.gitcopy'), } - beforeEach(async () => { + beforeEach(() => { rm('-rf', join(__dirname, 'output', 'extract', '.gitcopy')) }) - afterEach(async () => { + afterEach(() => { rm('-rf', destination) }) - afterAll(async () => { - rm('-rf', join(__dirname, 'output', 'extract', '.gitcopy')) + afterAll(() => { + rm('-rf', join(__dirname, 'output', 'extract')) }) it('should extract "lukeed/gittar"', async () => { diff --git a/src/utils/__test__/gitly.spec.ts b/src/utils/__test__/gitly.spec.ts index a9ea6db..a89a704 100644 --- a/src/utils/__test__/gitly.spec.ts +++ b/src/utils/__test__/gitly.spec.ts @@ -8,17 +8,17 @@ describe('gitly', () => { temp: join(__dirname, 'output', 'gitly'), } - beforeEach(async () => { + beforeEach(() => { rm('-rf', join(__dirname, 'output', 'gitly')) }) - afterEach(async () => { + afterEach(() => { rm('-rf', destination) }) it('should clone the repository using axios', async () => { const result = await gitly('lukeed/gittar', destination, options) - expect(await exists(result[0])).toBeDefined() - expect(await exists(result[1])).toBeDefined() + expect(await exists(result[0])).toBe(true) + expect(await exists(result[1])).toBe(true) }) it('should clone the repository using git', async () => { @@ -26,7 +26,7 @@ describe('gitly', () => { ...options, backend: 'git', }) - expect(await exists(result[0])).toBeDefined() - expect(await exists(result[1])).toBeDefined() + expect(await exists(result[0])).toBe(true) + expect(await exists(result[1])).toBe(true) }) })