mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-11-09 22:08:58 +01:00
24 lines
567 B
TypeScript
24 lines
567 B
TypeScript
import fsMock from 'mock-fs'
|
|
|
|
import { isExistingPath } from '../isExistingPath.js'
|
|
|
|
describe('utils/isExistingFile', () => {
|
|
afterEach(() => {
|
|
fsMock.restore()
|
|
})
|
|
|
|
it('should return true if the file exists', async () => {
|
|
fsMock({
|
|
'/file.txt': ''
|
|
}, { createCwd: false })
|
|
expect(await isExistingPath('/file.txt')).toBeTruthy()
|
|
})
|
|
|
|
it("should return false if the file doesn't exists", async () => {
|
|
fsMock({
|
|
'/file.txt': ''
|
|
}, { createCwd: false })
|
|
expect(await isExistingPath('/randomfile.txt')).toBeFalsy()
|
|
})
|
|
})
|