2023-07-20 22:00:11 +02:00
|
|
|
import test from 'node:test'
|
|
|
|
import assert from 'node:assert/strict'
|
|
|
|
|
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
|
|
|
|
2023-07-20 22:00:11 +02:00
|
|
|
await test('utils/isExistingPath', async (t) => {
|
2022-04-23 18:41:14 +02:00
|
|
|
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
|
|
|
})
|
2023-07-20 22:00:11 +02:00
|
|
|
assert.strictEqual(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
|
|
|
})
|
2023-07-20 22:00:11 +02:00
|
|
|
assert.strictEqual(await isExistingPath('/randomfile.txt'), false)
|
2021-06-09 20:31:45 +02:00
|
|
|
})
|
|
|
|
})
|