1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00
programming-challenges/cli/utils/__test__/isExistingPath.test.ts

25 lines
570 B
TypeScript
Raw Normal View History

import fsMock from 'mock-fs'
import tap from 'tap'
2022-02-19 18:30:29 +01:00
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)
})
})