Skip to content

Commit c449f74

Browse files
[Tests] Add test for existing hidden folder missing gitignore
Add a unit test for getOrCreateHiddenShopifyFolder verifying that when the .shopify directory already exists but .gitignore does not, the .gitignore file is properly created inside the hidden folder.
1 parent 1149f9f commit c449f74

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎packages/cli-kit/src/public/node/hidden-folder.test.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,21 @@ describe('getOrCreateHiddenShopifyFolder', () => {
4747
expect(writeFileSpy).not.toHaveBeenCalled()
4848
})
4949
})
50+
51+
test('creates .gitignore when hidden folder exists but .gitignore does not', async () => {
52+
await fs.inTemporaryDirectory(async (tmpDir) => {
53+
// Given
54+
const hiddenFolder = joinPath(tmpDir, '.shopify')
55+
await fs.mkdir(hiddenFolder)
56+
const gitignorePath = joinPath(hiddenFolder, '.gitignore')
57+
58+
// When
59+
await getOrCreateHiddenShopifyFolder(tmpDir)
60+
61+
// Then
62+
await expect(fs.fileExists(gitignorePath)).resolves.toBe(true)
63+
const gitignoreContent = await fs.readFile(gitignorePath)
64+
expect(gitignoreContent).toContain('# Ignore the entire .shopify directory')
65+
})
66+
})
5067
})

0 commit comments

Comments
 (0)