diff options
| author | 2023-04-28 01:36:44 +0800 | |
|---|---|---|
| committer | 2023-04-28 01:36:44 +0800 | |
| commit | dd84b9d64fb98746a230cd24233ff50a562c39c9 (patch) | |
| tree | b583261ef00b3afe72ec4d6dacb31e57779a6faf /packages/create-turbo/__tests__/isFolderEmpty.test.ts | |
| parent | 0b46fcd72ac34382387b2bcf9095233efbcc52f4 (diff) | |
| download | HydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.tar.gz HydroRoll-dd84b9d64fb98746a230cd24233ff50a562c39c9.zip | |
Diffstat (limited to 'packages/create-turbo/__tests__/isFolderEmpty.test.ts')
| -rw-r--r-- | packages/create-turbo/__tests__/isFolderEmpty.test.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/packages/create-turbo/__tests__/isFolderEmpty.test.ts b/packages/create-turbo/__tests__/isFolderEmpty.test.ts new file mode 100644 index 0000000..66b2310 --- /dev/null +++ b/packages/create-turbo/__tests__/isFolderEmpty.test.ts @@ -0,0 +1,41 @@ +import fs from "fs-extra"; +import path from "path"; +import { isFolderEmpty } from "../src/utils/isFolderEmpty"; +import { setupTestFixtures } from "@turbo/test-utils"; + +describe("isFolderEmpty", () => { + const { useFixture } = setupTestFixtures({ + directory: path.join(__dirname, "../"), + }); + + it("correctly identifies an empty directory", async () => { + const { root } = useFixture({ fixture: `is-folder-empty` }); + const result = isFolderEmpty(root); + expect(result.isEmpty).toEqual(true); + expect(result.conflicts).toEqual([]); + }); + + it("correctly identifies a directory with non-conflicting files", async () => { + const { root } = useFixture({ fixture: `is-folder-empty` }); + fs.writeFileSync(path.join(root, "LICENSE"), "MIT"); + const result = isFolderEmpty(root); + expect(result.isEmpty).toEqual(true); + expect(result.conflicts).toEqual([]); + }); + + it("correctly identifies a directory non-conflicting files (intelliJ)", async () => { + const { root } = useFixture({ fixture: `is-folder-empty` }); + fs.writeFileSync(path.join(root, "intellij-idea-config.iml"), "{}"); + const result = isFolderEmpty(root); + expect(result.isEmpty).toEqual(true); + expect(result.conflicts).toEqual([]); + }); + + it("correctly identifies a directory conflicting files", async () => { + const { root } = useFixture({ fixture: `is-folder-empty` }); + fs.writeFileSync(path.join(root, "README.md"), "my cool project"); + const result = isFolderEmpty(root); + expect(result.isEmpty).toEqual(false); + expect(result.conflicts).toEqual(["README.md"]); + }); +}); |
