1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-07-18 02:20:12 +02:00
programming-challenges/cli/utils/__test__/isExistingPath.test.ts

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)
})
})