UNPKG

@pega/custom-dx-components

Version:

Utility for building custom UI components

85 lines (60 loc) 2.03 kB
import fs from 'fs'; import path, {join} from 'path'; import inquirer from 'inquirer'; import chalk from 'chalk'; import { showVersion, addDebugLog, getJestFunctionalTestList } from '../../util.js'; import { JEST_TESTS_FUNCTIONAL_PATH } from '../../constants.js'; export const quarnUnquarnTests = async(answers) => { switch (answers.QuarUnQuar) { case "Quarantine" : await quarantineTests(answers); break; case "Unquarantine" : await unquarantineTests(answers); break; } } export const quarantineTests = async(answers) => { const testList = await getJestFunctionalTestList(answers.whichTests); const functionalPath = join(path.resolve(), JEST_TESTS_FUNCTIONAL_PATH); // rename .test to .notest for (const testName of testList) { const quarantineName = testName.replace(".test", ".notest"); fs.renameSync(join(functionalPath, testName), join(functionalPath, quarantineName)); } } export const unquarantineTests = async(answers) => { const testList = await getJestFunctionalTestList(answers.whichTests); const functionalPath = join(path.resolve(), JEST_TESTS_FUNCTIONAL_PATH); // rename .test to .notest for (const testName of testList) { const restoreName = testName.replace(".notest", ".test"); fs.renameSync(join(functionalPath, testName), join(functionalPath, restoreName)); } } export default async options => { addDebugLog("quarantine", "", "+"); await showVersion(); const quaranAnswers = await inquirer.prompt([ { name: 'QuarUnQuar', type: 'rawlist', message: `Quarantine or UnQuarantine tests`, choices: ["Quarantine", "Unquarantine"], default: 'Quarantine' }, { name: 'whichTests', type: 'rawlist', message: (answers) => `Which tests to ${answers.QuarUnQuar}`, default: 'ALL', choices: ["ALL", "Original", "Library"] } ]); // await showCurrentStatus(); await quarnUnquarnTests(quaranAnswers); addDebugLog("quarantine", "END", "-"); }