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

24 lines
526 B
TypeScript
Raw Normal View History

import fsMock from 'mock-fs'
import { isExistingPath } from '../isExistingPath'
describe('utils/isExistingFile', () => {
afterEach(async () => {
fsMock.restore()
})
it('should return true if the file exists', async () => {
fsMock({
'/file.txt': ''
})
expect(await isExistingPath('/file.txt')).toBeTruthy()
})
it("should return false if the file doesn't exists", async () => {
fsMock({
'/file.txt': ''
})
expect(await isExistingPath('/randomfile.txt')).toBeFalsy()
})
})