summaryrefslogtreecommitdiff
path: root/packages/create-astro/test/git.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'packages/create-astro/test/git.test.js')
-rw-r--r--packages/create-astro/test/git.test.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/packages/create-astro/test/git.test.js b/packages/create-astro/test/git.test.js
new file mode 100644
index 000000000..4b048156a
--- /dev/null
+++ b/packages/create-astro/test/git.test.js
@@ -0,0 +1,43 @@
+import { expect } from 'chai';
+
+import fs from 'fs';
+import { execa } from 'execa';
+
+import { git } from '../dist/index.js';
+import { setup } from './utils.js';
+
+describe('git', () => {
+ const fixture = setup();
+
+ it('none', async () => {
+ const context = { cwd: '', dryRun: true, prompt: (() => ({ git: false }))};
+ await git(context);
+
+ expect(fixture.hasMessage('Skipping Git initialization')).to.be.true;
+ })
+
+ it('already initialized', async () => {
+ const context = { git: true, cwd: './test/fixtures/not-empty', dryRun: true, prompt: (() => ({ git: false }))};
+ await execa('git', ['init'], { cwd: './test/fixtures/not-empty' });
+ await git(context);
+
+ expect(fixture.hasMessage('Git has already been initialized')).to.be.true;
+
+ // Cleanup
+ fs.rmSync('./test/fixtures/not-empty/.git', { recursive: true, force: true });
+ })
+
+ it('yes (--dry-run)', async () => {
+ const context = { cwd: '', dryRun: true, prompt: (() => ({ git: true }))};
+ await git(context);
+
+ expect(fixture.hasMessage('Skipping Git initialization')).to.be.true;
+ })
+
+ it('no (--dry-run)', async () => {
+ const context = { cwd: '', dryRun: true, prompt: (() => ({ git: false }))};
+ await git(context);
+
+ expect(fixture.hasMessage('Skipping Git initialization')).to.be.true;
+ })
+})