From dd84b9d64fb98746a230cd24233ff50a562c39c9 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 28 Apr 2023 01:36:44 +0800 Subject: --- packages/turbo-workspaces/__tests__/test-utils.ts | 153 ++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 packages/turbo-workspaces/__tests__/test-utils.ts (limited to 'packages/turbo-workspaces/__tests__/test-utils.ts') diff --git a/packages/turbo-workspaces/__tests__/test-utils.ts b/packages/turbo-workspaces/__tests__/test-utils.ts new file mode 100644 index 0000000..4d6c7c9 --- /dev/null +++ b/packages/turbo-workspaces/__tests__/test-utils.ts @@ -0,0 +1,153 @@ +import { PackageManager } from "../src/types"; + +const PACKAGE_MANAGERS: Array = ["pnpm", "npm", "yarn"]; +const REPO_TYPES = ["monorepo", "non-monorepo"]; +const BOOLEAN_OPTIONS = [true, false]; + +export function generateConvertMatrix() { + const matrix = []; + for (const fixtureManager of PACKAGE_MANAGERS) { + for (const fixtureType of REPO_TYPES) { + for (const toManager of PACKAGE_MANAGERS) { + for (const interactive of BOOLEAN_OPTIONS) { + for (const dry of BOOLEAN_OPTIONS) { + for (const install of BOOLEAN_OPTIONS) { + matrix.push({ + fixtureManager, + fixtureType, + toManager, + interactive, + dry, + install, + }); + } + } + } + } + } + } + return matrix; +} + +export function generateDetectMatrix() { + const matrix = []; + for (const project of PACKAGE_MANAGERS) { + for (const manager of PACKAGE_MANAGERS) { + for (const type of REPO_TYPES) { + matrix.push({ + project, + manager, + type, + result: project === manager, + }); + } + } + } + return matrix; +} + +export function generateCreateMatrix() { + const matrix = []; + for (const project of PACKAGE_MANAGERS) { + for (const manager of PACKAGE_MANAGERS) { + for (const type of REPO_TYPES) { + for (const interactive of BOOLEAN_OPTIONS) { + for (const dry of BOOLEAN_OPTIONS) { + matrix.push({ + project, + manager, + type, + interactive, + dry, + }); + } + } + } + } + } + return matrix; +} + +export function generateReadMatrix() { + const matrix = []; + for (const fixtureManager of PACKAGE_MANAGERS) { + for (const fixtureType of REPO_TYPES) { + for (const toManager of PACKAGE_MANAGERS) { + matrix.push({ + fixtureManager, + fixtureType, + toManager, + shouldThrow: fixtureManager !== toManager, + }); + } + } + } + + return matrix; +} + +export function generateRemoveMatrix() { + const matrix = []; + for (const fixtureManager of PACKAGE_MANAGERS) { + for (const fixtureType of REPO_TYPES) { + for (const toManager of PACKAGE_MANAGERS) { + for (const withNodeModules of BOOLEAN_OPTIONS) { + for (const interactive of BOOLEAN_OPTIONS) { + for (const dry of BOOLEAN_OPTIONS) { + matrix.push({ + fixtureManager, + fixtureType, + withNodeModules, + toManager, + interactive, + dry, + }); + } + } + } + } + } + } + return matrix; +} + +export function generateCleanMatrix() { + const matrix = []; + for (const fixtureManager of PACKAGE_MANAGERS) { + for (const fixtureType of REPO_TYPES) { + for (const interactive of BOOLEAN_OPTIONS) { + for (const dry of BOOLEAN_OPTIONS) { + matrix.push({ + fixtureManager, + fixtureType, + interactive, + dry, + }); + } + } + } + } + return matrix; +} + +export function generateConvertLockMatrix() { + const matrix = []; + for (const fixtureManager of PACKAGE_MANAGERS) { + for (const fixtureType of REPO_TYPES) { + for (const toManager of PACKAGE_MANAGERS) { + for (const interactive of BOOLEAN_OPTIONS) { + for (const dry of BOOLEAN_OPTIONS) { + matrix.push({ + fixtureManager, + fixtureType, + toManager, + interactive, + dry, + }); + } + } + } + } + } + return matrix; +} -- cgit v1.2.3-70-g09d2