summaryrefslogtreecommitdiff
path: root/packages/create-astro/test/astro-add-step.test.js
diff options
context:
space:
mode:
authorGravatar Fred K. Schott <fkschott@gmail.com> 2022-06-27 14:15:51 -0700
committerGravatar GitHub <noreply@github.com> 2022-06-27 14:15:51 -0700
commit4d6d8644e623522ca6c19dbb2078865b17044c38 (patch)
treec0d0f032785dc5b5ba1386612281b5b8a6e52715 /packages/create-astro/test/astro-add-step.test.js
parentbd4dac0e1a8598045f10c42faf08abff96ed6766 (diff)
downloadastro-4d6d8644e623522ca6c19dbb2078865b17044c38.tar.gz
astro-4d6d8644e623522ca6c19dbb2078865b17044c38.tar.zst
astro-4d6d8644e623522ca6c19dbb2078865b17044c38.zip
SImplify "astro add" by removing confusing multi-select (#3715)
* wip * update create-astro for new astro add * update copy * update git prompt * Update packages/astro/src/core/logger/node.ts Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * Update packages/create-astro/test/install-step.test.js Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * update git prompt * update test Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
Diffstat (limited to 'packages/create-astro/test/astro-add-step.test.js')
-rw-r--r--packages/create-astro/test/astro-add-step.test.js69
1 files changed, 0 insertions, 69 deletions
diff --git a/packages/create-astro/test/astro-add-step.test.js b/packages/create-astro/test/astro-add-step.test.js
deleted file mode 100644
index 73d963ed0..000000000
--- a/packages/create-astro/test/astro-add-step.test.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import { setup, promiseWithTimeout, timeout, PROMPT_MESSAGES } from './utils.js';
-import { sep } from 'path';
-import fs from 'fs';
-import os from 'os';
-
-// reset package manager in process.env
-// prevents test issues when running with pnpm
-const FAKE_PACKAGE_MANAGER = 'npm';
-let initialEnvValue = null;
-
-describe('[create-astro] astro add', function () {
- this.timeout(timeout);
- let tempDir = '';
- beforeEach(async () => {
- tempDir = await fs.promises.mkdtemp(`${os.tmpdir()}${sep}`);
- });
- this.beforeAll(() => {
- initialEnvValue = process.env.npm_config_user_agent;
- process.env.npm_config_user_agent = FAKE_PACKAGE_MANAGER;
- });
- this.afterAll(() => {
- process.env.npm_config_user_agent = initialEnvValue;
- });
-
- it('should use "astro add" when user has installed dependencies', function () {
- const { stdout, stdin } = setup([tempDir]);
- return promiseWithTimeout((resolve) => {
- const seen = new Set();
- const installPrompt = PROMPT_MESSAGES.install('npm');
- stdout.on('data', (chunk) => {
- if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) {
- seen.add(PROMPT_MESSAGES.template);
- // respond with "enter key"
- stdin.write('\x0D');
- }
- if (!seen.has(installPrompt) && chunk.includes(installPrompt)) {
- seen.add(installPrompt);
- stdin.write('\x0D');
- }
- if (chunk.includes(PROMPT_MESSAGES.astroAdd('astro add --yes'))) {
- resolve();
- }
- });
- });
- });
-
- it('should use "npx astro@latest add" when use has NOT installed dependencies', function () {
- const { stdout, stdin } = setup([tempDir]);
- return promiseWithTimeout((resolve) => {
- const seen = new Set();
- const installPrompt = PROMPT_MESSAGES.install('npm');
- stdout.on('data', (chunk) => {
- if (!seen.has(PROMPT_MESSAGES.template) && chunk.includes(PROMPT_MESSAGES.template)) {
- seen.add(PROMPT_MESSAGES.template);
- // respond with "enter key"
- stdin.write('\x0D');
- }
- if (!seen.has(installPrompt) && chunk.includes(installPrompt)) {
- seen.add(installPrompt);
- // respond with "no, then enter key"
- stdin.write('n\x0D');
- }
- if (chunk.includes(PROMPT_MESSAGES.astroAdd('npx astro@latest add --yes'))) {
- resolve();
- }
- });
- });
- });
-});