1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00
programming-challenges/cli/utils/__test__/createTemporaryEmptyFolder.test.ts

28 lines
739 B
TypeScript
Raw Normal View History

import fs from 'node:fs'
import fsMock from 'mock-fs'
import {
TEMPORARY_PATH,
createTemporaryEmptyFolder
} from '../createTemporaryEmptyFolder'
import { isExistingPath } from '../isExistingPath'
describe('utils/createTemporaryEmptyFolder', () => {
afterEach(async () => {
fsMock.restore()
})
it('should remove and create again the temporary folder', async () => {
fsMock({
[TEMPORARY_PATH]: {
'file.txt': ''
}
2021-12-06 17:18:14 +01:00
}, { createCwd: false })
expect(await isExistingPath(TEMPORARY_PATH)).toBeTruthy()
expect((await fs.promises.readdir(TEMPORARY_PATH)).length).toEqual(1)
await createTemporaryEmptyFolder()
expect((await fs.promises.readdir(TEMPORARY_PATH)).length).toEqual(0)
})
})