Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Takeshi committed Feb 17, 2024
1 parent fe9dd07 commit 3a40916
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
9 changes: 7 additions & 2 deletions src/utils/__test__/download.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
})

Expand Down
10 changes: 5 additions & 5 deletions src/utils/__test__/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
12 changes: 6 additions & 6 deletions src/utils/__test__/gitly.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ 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 () => {
const result = await gitly('lukeed/gittar', destination, {
...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)
})
})

0 comments on commit 3a40916

Please sign in to comment.