0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/create-astro/test/git.test.js
Erika f14e48098a
nit: use node: prefix everywhere (#7692)
* nit: use `node:` prefix everywhere

* nit: fs/promises too

* test: workaround issue in node builtin detection
2023-07-18 02:17:59 +02:00

48 lines
1.3 KiB
JavaScript

import { expect } from 'chai';
import { execa } from 'execa';
import fs from 'node:fs';
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;
});
});