2021-06-09 20:31:45 +02:00
|
|
|
import fsMock from 'mock-fs'
|
2022-04-23 18:41:14 +02:00
|
|
|
import tap from 'tap'
|
2021-06-09 20:31:45 +02:00
|
|
|
|
2022-02-19 18:30:29 +01:00
|
|
|
import { isExistingPath } from '../isExistingPath.js'
|
2021-06-09 20:31:45 +02:00
|
|
|
|
2022-04-23 18:41:14 +02:00
|
|
|
await tap.test('utils/isExistingPath', async (t) => {
|
|
|
|
t.afterEach(() => {
|
2021-06-09 20:31:45 +02:00
|
|
|
fsMock.restore()
|
|
|
|
})
|
|
|
|
|
2022-04-23 18:41:14 +02:00
|
|
|
await t.test('should return true if the file exists', async () => {
|
2021-06-09 20:31:45 +02:00
|
|
|
fsMock({
|
|
|
|
'/file.txt': ''
|
2022-04-23 18:41:14 +02:00
|
|
|
})
|
|
|
|
t.equal(await isExistingPath('/file.txt'), true)
|
2021-06-09 20:31:45 +02:00
|
|
|
})
|
|
|
|
|
2022-04-23 18:41:14 +02:00
|
|
|
await t.test("should return false if the file doesn't exists", async () => {
|
2021-06-09 20:31:45 +02:00
|
|
|
fsMock({
|
|
|
|
'/file.txt': ''
|
2022-04-23 18:41:14 +02:00
|
|
|
})
|
|
|
|
t.equal(await isExistingPath('/randomfile.txt'), false)
|
2021-06-09 20:31:45 +02:00
|
|
|
})
|
|
|
|
})
|