From 472bbf1809fc1d31b12489e65c01e72d16726997 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Tue, 1 Aug 2023 01:55:05 +0500 Subject: [PATCH] test: make sure paths never start with ./ --- __tests__/fdir.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/__tests__/fdir.test.ts b/__tests__/fdir.test.ts index 64ca833..ac062c3 100644 --- a/__tests__/fdir.test.ts +++ b/__tests__/fdir.test.ts @@ -385,6 +385,22 @@ test(`[async] crawl directory & use abort signal to abort`, async (t) => { t.expect(files.length).toBeLessThan(totalFiles.files); }); +test(`paths should never start with ./`, async (t) => { + const apis = [ + new fdir().withBasePath().crawl("./node_modules"), + new fdir().withBasePath().crawl("./"), + new fdir().withRelativePaths().crawl("./"), + new fdir().withDirs().crawl("."), + new fdir().onlyDirs().crawl("."), + ]; + for (const api of apis) { + const files = await api.withPromise(); + t.expect( + files.every((file) => !file.startsWith("./") && !file.startsWith(".\\")) + ).toBe(true); + } +}); + test(`ignore withRelativePath if root === ./`, async (t) => { const relativeFiles = await new fdir() .withRelativePaths()