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