2021-06-09 20:31:45 +02:00
|
|
|
import fsMock from 'mock-fs'
|
|
|
|
|
2022-02-19 18:30:29 +01:00
|
|
|
import { isExistingPath } from '../isExistingPath.js'
|
2021-06-09 20:31:45 +02:00
|
|
|
|
|
|
|
describe('utils/isExistingFile', () => {
|
2022-02-19 18:30:29 +01:00
|
|
|
afterEach(() => {
|
2021-06-09 20:31:45 +02:00
|
|
|
fsMock.restore()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('should return true if the file exists', async () => {
|
|
|
|
fsMock({
|
|
|
|
'/file.txt': ''
|
2021-12-06 17:18:14 +01:00
|
|
|
}, { createCwd: false })
|
2021-06-09 20:31:45 +02:00
|
|
|
expect(await isExistingPath('/file.txt')).toBeTruthy()
|
|
|
|
})
|
|
|
|
|
|
|
|
it("should return false if the file doesn't exists", async () => {
|
|
|
|
fsMock({
|
|
|
|
'/file.txt': ''
|
2021-12-06 17:18:14 +01:00
|
|
|
}, { createCwd: false })
|
2021-06-09 20:31:45 +02:00
|
|
|
expect(await isExistingPath('/randomfile.txt')).toBeFalsy()
|
|
|
|
})
|
|
|
|
})
|