From 6615859f00f77b8a3e3d50fa5dc8d32d0c3a62f8 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder <231804+danez@users.noreply.github.com> Date: Mon, 16 Jan 2023 15:44:22 +0100 Subject: [PATCH] chore: fix tests --- packages/framework-info/.gitignore | 6 ++-- packages/framework-info/test/options.test.ts | 29 ------------------- .../__snapshots__/main.test.ts.snap | 0 .../{test => tests}/detect.test.ts | 0 .../{test => tests}/dev.test.ts | 0 .../fixtures/colon_scripts/package.json | 0 .../fixtures/config_files/config.rb | 0 .../fixtures/config_files/package.json | 0 .../fixtures/dependencies/package.json | 0 .../fixtures/dev_command_scripts/package.json | 0 .../fixtures/dev_dependencies/package.json | 0 .../{test => tests}/fixtures/empty/.gitkeep | 0 .../fixtures/empty/package.json | 0 .../fixtures/empty_dependencies/config.rb | 0 .../fixtures/empty_dependencies/package.json | 0 .../fixtures/empty_scripts/package.json | 0 .../excluded_dependencies/package.json | 0 .../fixtures/excluded_script/package.json | 0 .../invalid_dependencies/package.json | 0 .../fixtures/invalid_package/package.json | 0 .../fixtures/invalid_scripts/package.json | 0 .../fixtures/monorepos/app1/package.json | 0 .../fixtures/monorepos/app2/package.json | 0 .../monorepos/node_modules/next/package.json | 0 .../@vue/cli-service/package.json | 0 .../node_modules/vuepress/package.json | 0 .../fixtures/multiple/package.json | 0 .../fixtures/next-plugin/package.json | 0 .../fixtures/no_package/config.rb | 0 .../{test => tests}/fixtures/package.json | 0 .../fixtures/parent_package/package.json | 0 .../scripts-order/build-first/package.json | 0 .../command-substring/package.json | 0 .../scripts-order/dev-first/package.json | 0 .../scripts-order/postfix-format/package.json | 0 .../scripts-order/vite-framework/package.json | 0 .../several_dependencies/package.json | 0 .../simple/node_modules/sapper/package.json | 0 .../fixtures/simple/package.json | 0 .../fixtures/syntax_package/package.json | 0 .../fixtures/use_scripts/package.json | 0 .../fixtures/yarn_scripts/package.json | 0 .../fixtures/yarn_scripts/yarn.lock | 0 .../{test => tests}/frameworks.test.ts | 0 .../{test => tests}/helpers/main.ts | 0 .../{test => tests}/main.test.ts | 0 packages/framework-info/tests/options.test.ts | 21 ++++++++++++++ .../{test => tests}/package.test.ts | 0 .../{test => tests}/run_script.test.ts | 0 49 files changed, 24 insertions(+), 32 deletions(-) delete mode 100644 packages/framework-info/test/options.test.ts rename packages/framework-info/{test => tests}/__snapshots__/main.test.ts.snap (100%) rename packages/framework-info/{test => tests}/detect.test.ts (100%) rename packages/framework-info/{test => tests}/dev.test.ts (100%) rename packages/framework-info/{test => tests}/fixtures/colon_scripts/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/config_files/config.rb (100%) rename packages/framework-info/{test => tests}/fixtures/config_files/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/dependencies/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/dev_command_scripts/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/dev_dependencies/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/empty/.gitkeep (100%) rename packages/framework-info/{test => tests}/fixtures/empty/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/empty_dependencies/config.rb (100%) rename packages/framework-info/{test => tests}/fixtures/empty_dependencies/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/empty_scripts/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/excluded_dependencies/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/excluded_script/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/invalid_dependencies/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/invalid_package/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/invalid_scripts/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/monorepos/app1/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/monorepos/app2/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/monorepos/node_modules/next/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/multiple/node_modules/@vue/cli-service/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/multiple/node_modules/vuepress/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/multiple/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/next-plugin/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/no_package/config.rb (100%) rename packages/framework-info/{test => tests}/fixtures/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/parent_package/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/scripts-order/build-first/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/scripts-order/command-substring/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/scripts-order/dev-first/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/scripts-order/postfix-format/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/scripts-order/vite-framework/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/several_dependencies/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/simple/node_modules/sapper/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/simple/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/syntax_package/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/use_scripts/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/yarn_scripts/package.json (100%) rename packages/framework-info/{test => tests}/fixtures/yarn_scripts/yarn.lock (100%) rename packages/framework-info/{test => tests}/frameworks.test.ts (100%) rename packages/framework-info/{test => tests}/helpers/main.ts (100%) rename packages/framework-info/{test => tests}/main.test.ts (100%) create mode 100644 packages/framework-info/tests/options.test.ts rename packages/framework-info/{test => tests}/package.test.ts (100%) rename packages/framework-info/{test => tests}/run_script.test.ts (100%) diff --git a/packages/framework-info/.gitignore b/packages/framework-info/.gitignore index b24b59c5f7..67ed40ad8a 100644 --- a/packages/framework-info/.gitignore +++ b/packages/framework-info/.gitignore @@ -9,6 +9,6 @@ src/generated .netlify # These are mock node_modules folder for testing purposes -!test/fixtures/simple/node_modules -!test/fixtures/multiple/node_modules -!test/fixtures/monorepos/node_modules +!tests/fixtures/simple/node_modules +!tests/fixtures/multiple/node_modules +!tests/fixtures/monorepos/node_modules diff --git a/packages/framework-info/test/options.test.ts b/packages/framework-info/test/options.test.ts deleted file mode 100644 index 4b902c0ef4..0000000000 --- a/packages/framework-info/test/options.test.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { cwd, chdir } from 'process' - -import { expect, test } from 'vitest' - -import { listFrameworks } from '../src/main.js' - -import { FIXTURES_DIR } from './helpers/main.js' - -test('projectDir option defaults to process.cwd()', async () => { - const oldCwd = cwd() - chdir(`${FIXTURES_DIR}/simple`) - try { - const frameworks = await listFrameworks({}) - expect(frameworks).toHaveLength(1) - } finally { - chdir(oldCwd) - } -}) - -test('Can trigger with no options', async () => { - const oldCwd = cwd() - chdir(`${FIXTURES_DIR}/simple`) - try { - const frameworks = await listFrameworks() - expect(frameworks).toHaveLength(1) - } finally { - chdir(oldCwd) - } -}) diff --git a/packages/framework-info/test/__snapshots__/main.test.ts.snap b/packages/framework-info/tests/__snapshots__/main.test.ts.snap similarity index 100% rename from packages/framework-info/test/__snapshots__/main.test.ts.snap rename to packages/framework-info/tests/__snapshots__/main.test.ts.snap diff --git a/packages/framework-info/test/detect.test.ts b/packages/framework-info/tests/detect.test.ts similarity index 100% rename from packages/framework-info/test/detect.test.ts rename to packages/framework-info/tests/detect.test.ts diff --git a/packages/framework-info/test/dev.test.ts b/packages/framework-info/tests/dev.test.ts similarity index 100% rename from packages/framework-info/test/dev.test.ts rename to packages/framework-info/tests/dev.test.ts diff --git a/packages/framework-info/test/fixtures/colon_scripts/package.json b/packages/framework-info/tests/fixtures/colon_scripts/package.json similarity index 100% rename from packages/framework-info/test/fixtures/colon_scripts/package.json rename to packages/framework-info/tests/fixtures/colon_scripts/package.json diff --git a/packages/framework-info/test/fixtures/config_files/config.rb b/packages/framework-info/tests/fixtures/config_files/config.rb similarity index 100% rename from packages/framework-info/test/fixtures/config_files/config.rb rename to packages/framework-info/tests/fixtures/config_files/config.rb diff --git a/packages/framework-info/test/fixtures/config_files/package.json b/packages/framework-info/tests/fixtures/config_files/package.json similarity index 100% rename from packages/framework-info/test/fixtures/config_files/package.json rename to packages/framework-info/tests/fixtures/config_files/package.json diff --git a/packages/framework-info/test/fixtures/dependencies/package.json b/packages/framework-info/tests/fixtures/dependencies/package.json similarity index 100% rename from packages/framework-info/test/fixtures/dependencies/package.json rename to packages/framework-info/tests/fixtures/dependencies/package.json diff --git a/packages/framework-info/test/fixtures/dev_command_scripts/package.json b/packages/framework-info/tests/fixtures/dev_command_scripts/package.json similarity index 100% rename from packages/framework-info/test/fixtures/dev_command_scripts/package.json rename to packages/framework-info/tests/fixtures/dev_command_scripts/package.json diff --git a/packages/framework-info/test/fixtures/dev_dependencies/package.json b/packages/framework-info/tests/fixtures/dev_dependencies/package.json similarity index 100% rename from packages/framework-info/test/fixtures/dev_dependencies/package.json rename to packages/framework-info/tests/fixtures/dev_dependencies/package.json diff --git a/packages/framework-info/test/fixtures/empty/.gitkeep b/packages/framework-info/tests/fixtures/empty/.gitkeep similarity index 100% rename from packages/framework-info/test/fixtures/empty/.gitkeep rename to packages/framework-info/tests/fixtures/empty/.gitkeep diff --git a/packages/framework-info/test/fixtures/empty/package.json b/packages/framework-info/tests/fixtures/empty/package.json similarity index 100% rename from packages/framework-info/test/fixtures/empty/package.json rename to packages/framework-info/tests/fixtures/empty/package.json diff --git a/packages/framework-info/test/fixtures/empty_dependencies/config.rb b/packages/framework-info/tests/fixtures/empty_dependencies/config.rb similarity index 100% rename from packages/framework-info/test/fixtures/empty_dependencies/config.rb rename to packages/framework-info/tests/fixtures/empty_dependencies/config.rb diff --git a/packages/framework-info/test/fixtures/empty_dependencies/package.json b/packages/framework-info/tests/fixtures/empty_dependencies/package.json similarity index 100% rename from packages/framework-info/test/fixtures/empty_dependencies/package.json rename to packages/framework-info/tests/fixtures/empty_dependencies/package.json diff --git a/packages/framework-info/test/fixtures/empty_scripts/package.json b/packages/framework-info/tests/fixtures/empty_scripts/package.json similarity index 100% rename from packages/framework-info/test/fixtures/empty_scripts/package.json rename to packages/framework-info/tests/fixtures/empty_scripts/package.json diff --git a/packages/framework-info/test/fixtures/excluded_dependencies/package.json b/packages/framework-info/tests/fixtures/excluded_dependencies/package.json similarity index 100% rename from packages/framework-info/test/fixtures/excluded_dependencies/package.json rename to packages/framework-info/tests/fixtures/excluded_dependencies/package.json diff --git a/packages/framework-info/test/fixtures/excluded_script/package.json b/packages/framework-info/tests/fixtures/excluded_script/package.json similarity index 100% rename from packages/framework-info/test/fixtures/excluded_script/package.json rename to packages/framework-info/tests/fixtures/excluded_script/package.json diff --git a/packages/framework-info/test/fixtures/invalid_dependencies/package.json b/packages/framework-info/tests/fixtures/invalid_dependencies/package.json similarity index 100% rename from packages/framework-info/test/fixtures/invalid_dependencies/package.json rename to packages/framework-info/tests/fixtures/invalid_dependencies/package.json diff --git a/packages/framework-info/test/fixtures/invalid_package/package.json b/packages/framework-info/tests/fixtures/invalid_package/package.json similarity index 100% rename from packages/framework-info/test/fixtures/invalid_package/package.json rename to packages/framework-info/tests/fixtures/invalid_package/package.json diff --git a/packages/framework-info/test/fixtures/invalid_scripts/package.json b/packages/framework-info/tests/fixtures/invalid_scripts/package.json similarity index 100% rename from packages/framework-info/test/fixtures/invalid_scripts/package.json rename to packages/framework-info/tests/fixtures/invalid_scripts/package.json diff --git a/packages/framework-info/test/fixtures/monorepos/app1/package.json b/packages/framework-info/tests/fixtures/monorepos/app1/package.json similarity index 100% rename from packages/framework-info/test/fixtures/monorepos/app1/package.json rename to packages/framework-info/tests/fixtures/monorepos/app1/package.json diff --git a/packages/framework-info/test/fixtures/monorepos/app2/package.json b/packages/framework-info/tests/fixtures/monorepos/app2/package.json similarity index 100% rename from packages/framework-info/test/fixtures/monorepos/app2/package.json rename to packages/framework-info/tests/fixtures/monorepos/app2/package.json diff --git a/packages/framework-info/test/fixtures/monorepos/node_modules/next/package.json b/packages/framework-info/tests/fixtures/monorepos/node_modules/next/package.json similarity index 100% rename from packages/framework-info/test/fixtures/monorepos/node_modules/next/package.json rename to packages/framework-info/tests/fixtures/monorepos/node_modules/next/package.json diff --git a/packages/framework-info/test/fixtures/multiple/node_modules/@vue/cli-service/package.json b/packages/framework-info/tests/fixtures/multiple/node_modules/@vue/cli-service/package.json similarity index 100% rename from packages/framework-info/test/fixtures/multiple/node_modules/@vue/cli-service/package.json rename to packages/framework-info/tests/fixtures/multiple/node_modules/@vue/cli-service/package.json diff --git a/packages/framework-info/test/fixtures/multiple/node_modules/vuepress/package.json b/packages/framework-info/tests/fixtures/multiple/node_modules/vuepress/package.json similarity index 100% rename from packages/framework-info/test/fixtures/multiple/node_modules/vuepress/package.json rename to packages/framework-info/tests/fixtures/multiple/node_modules/vuepress/package.json diff --git a/packages/framework-info/test/fixtures/multiple/package.json b/packages/framework-info/tests/fixtures/multiple/package.json similarity index 100% rename from packages/framework-info/test/fixtures/multiple/package.json rename to packages/framework-info/tests/fixtures/multiple/package.json diff --git a/packages/framework-info/test/fixtures/next-plugin/package.json b/packages/framework-info/tests/fixtures/next-plugin/package.json similarity index 100% rename from packages/framework-info/test/fixtures/next-plugin/package.json rename to packages/framework-info/tests/fixtures/next-plugin/package.json diff --git a/packages/framework-info/test/fixtures/no_package/config.rb b/packages/framework-info/tests/fixtures/no_package/config.rb similarity index 100% rename from packages/framework-info/test/fixtures/no_package/config.rb rename to packages/framework-info/tests/fixtures/no_package/config.rb diff --git a/packages/framework-info/test/fixtures/package.json b/packages/framework-info/tests/fixtures/package.json similarity index 100% rename from packages/framework-info/test/fixtures/package.json rename to packages/framework-info/tests/fixtures/package.json diff --git a/packages/framework-info/test/fixtures/parent_package/package.json b/packages/framework-info/tests/fixtures/parent_package/package.json similarity index 100% rename from packages/framework-info/test/fixtures/parent_package/package.json rename to packages/framework-info/tests/fixtures/parent_package/package.json diff --git a/packages/framework-info/test/fixtures/scripts-order/build-first/package.json b/packages/framework-info/tests/fixtures/scripts-order/build-first/package.json similarity index 100% rename from packages/framework-info/test/fixtures/scripts-order/build-first/package.json rename to packages/framework-info/tests/fixtures/scripts-order/build-first/package.json diff --git a/packages/framework-info/test/fixtures/scripts-order/command-substring/package.json b/packages/framework-info/tests/fixtures/scripts-order/command-substring/package.json similarity index 100% rename from packages/framework-info/test/fixtures/scripts-order/command-substring/package.json rename to packages/framework-info/tests/fixtures/scripts-order/command-substring/package.json diff --git a/packages/framework-info/test/fixtures/scripts-order/dev-first/package.json b/packages/framework-info/tests/fixtures/scripts-order/dev-first/package.json similarity index 100% rename from packages/framework-info/test/fixtures/scripts-order/dev-first/package.json rename to packages/framework-info/tests/fixtures/scripts-order/dev-first/package.json diff --git a/packages/framework-info/test/fixtures/scripts-order/postfix-format/package.json b/packages/framework-info/tests/fixtures/scripts-order/postfix-format/package.json similarity index 100% rename from packages/framework-info/test/fixtures/scripts-order/postfix-format/package.json rename to packages/framework-info/tests/fixtures/scripts-order/postfix-format/package.json diff --git a/packages/framework-info/test/fixtures/scripts-order/vite-framework/package.json b/packages/framework-info/tests/fixtures/scripts-order/vite-framework/package.json similarity index 100% rename from packages/framework-info/test/fixtures/scripts-order/vite-framework/package.json rename to packages/framework-info/tests/fixtures/scripts-order/vite-framework/package.json diff --git a/packages/framework-info/test/fixtures/several_dependencies/package.json b/packages/framework-info/tests/fixtures/several_dependencies/package.json similarity index 100% rename from packages/framework-info/test/fixtures/several_dependencies/package.json rename to packages/framework-info/tests/fixtures/several_dependencies/package.json diff --git a/packages/framework-info/test/fixtures/simple/node_modules/sapper/package.json b/packages/framework-info/tests/fixtures/simple/node_modules/sapper/package.json similarity index 100% rename from packages/framework-info/test/fixtures/simple/node_modules/sapper/package.json rename to packages/framework-info/tests/fixtures/simple/node_modules/sapper/package.json diff --git a/packages/framework-info/test/fixtures/simple/package.json b/packages/framework-info/tests/fixtures/simple/package.json similarity index 100% rename from packages/framework-info/test/fixtures/simple/package.json rename to packages/framework-info/tests/fixtures/simple/package.json diff --git a/packages/framework-info/test/fixtures/syntax_package/package.json b/packages/framework-info/tests/fixtures/syntax_package/package.json similarity index 100% rename from packages/framework-info/test/fixtures/syntax_package/package.json rename to packages/framework-info/tests/fixtures/syntax_package/package.json diff --git a/packages/framework-info/test/fixtures/use_scripts/package.json b/packages/framework-info/tests/fixtures/use_scripts/package.json similarity index 100% rename from packages/framework-info/test/fixtures/use_scripts/package.json rename to packages/framework-info/tests/fixtures/use_scripts/package.json diff --git a/packages/framework-info/test/fixtures/yarn_scripts/package.json b/packages/framework-info/tests/fixtures/yarn_scripts/package.json similarity index 100% rename from packages/framework-info/test/fixtures/yarn_scripts/package.json rename to packages/framework-info/tests/fixtures/yarn_scripts/package.json diff --git a/packages/framework-info/test/fixtures/yarn_scripts/yarn.lock b/packages/framework-info/tests/fixtures/yarn_scripts/yarn.lock similarity index 100% rename from packages/framework-info/test/fixtures/yarn_scripts/yarn.lock rename to packages/framework-info/tests/fixtures/yarn_scripts/yarn.lock diff --git a/packages/framework-info/test/frameworks.test.ts b/packages/framework-info/tests/frameworks.test.ts similarity index 100% rename from packages/framework-info/test/frameworks.test.ts rename to packages/framework-info/tests/frameworks.test.ts diff --git a/packages/framework-info/test/helpers/main.ts b/packages/framework-info/tests/helpers/main.ts similarity index 100% rename from packages/framework-info/test/helpers/main.ts rename to packages/framework-info/tests/helpers/main.ts diff --git a/packages/framework-info/test/main.test.ts b/packages/framework-info/tests/main.test.ts similarity index 100% rename from packages/framework-info/test/main.test.ts rename to packages/framework-info/tests/main.test.ts diff --git a/packages/framework-info/tests/options.test.ts b/packages/framework-info/tests/options.test.ts new file mode 100644 index 0000000000..6dbe3215f7 --- /dev/null +++ b/packages/framework-info/tests/options.test.ts @@ -0,0 +1,21 @@ +import process from 'process' + +import { expect, test, vi } from 'vitest' + +import { listFrameworks } from '../src/main.js' + +import { FIXTURES_DIR } from './helpers/main.js' + +test('projectDir option defaults to process.cwd()', async () => { + const spyInstance = vi.spyOn(process, 'cwd').mockReturnValue(`${FIXTURES_DIR}/simple`) + const frameworks = await listFrameworks({}) + expect(frameworks).toHaveLength(1) + spyInstance.mockRestore() +}) + +test('Can trigger with no options', async () => { + const spyInstance = vi.spyOn(process, 'cwd').mockReturnValue(`${FIXTURES_DIR}/simple`) + const frameworks = await listFrameworks() + expect(frameworks).toHaveLength(1) + spyInstance.mockRestore() +}) diff --git a/packages/framework-info/test/package.test.ts b/packages/framework-info/tests/package.test.ts similarity index 100% rename from packages/framework-info/test/package.test.ts rename to packages/framework-info/tests/package.test.ts diff --git a/packages/framework-info/test/run_script.test.ts b/packages/framework-info/tests/run_script.test.ts similarity index 100% rename from packages/framework-info/test/run_script.test.ts rename to packages/framework-info/tests/run_script.test.ts