AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.124
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/wwwroot/mifepriston.org/node_modules/webpack-cli/lib/utils/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/wwwroot/mifepriston.org/node_modules/webpack-cli/lib/utils/defineTest.js
"use strict";

const fs = require("fs");
const path = require("path");

/**
 * Utility function to run a jscodeshift script within a unit test.
 * This makes several assumptions about the environment.
 *
 * Notes:
 * - The test should be located in a subdirectory next to the transform itself.
 *   Commonly tests are located in a directory called __tests__.
 *
 * - Test data should be located in a directory called __testfixtures__
 *   alongside the transform and __tests__ directory.
 * @param  {String} dirName          contains the name of the directory the test is located in. This
 *                                   should normally be passed via __dirname.
 * @param  {String} transformName    contains the filename of the transform being tested,
 *                                   excluding the .js extension.
 * @param  {String} [testFilePrefix] Optionally contains the name of the file with the test
 *                                   data. If not specified, it defaults to the same value as `transformName`.
 *                                   This will be suffixed with ".input.js" for the input file and ".output.js"
 *                                   for the expected output. For example, if set to "foo", we will read the
 *                                   "foo.input.js" file, pass this to the transform, and expect its output to
 *                                   be equal to the contents of "foo.output.js".
 * @param  {Object|Boolean|String} initOptions TBD
 * @param  {String} action init, update or remove, decides how to format the AST
 * @return {Function} Function that fires of the transforms
 */
function runSingleTransform(
	dirName,
	transformName,
	testFilePrefix,
	initOptions,
	action
) {
	if (!testFilePrefix) {
		testFilePrefix = transformName;
	}
	const fixtureDir = path.join(dirName, "__testfixtures__");
	const inputPath = path.join(fixtureDir, testFilePrefix + ".input.js");
	const source = fs.readFileSync(inputPath, "utf8");
	// Assumes transform and test are on the same level
	const module = require(path.join(dirName, transformName + ".js"));
	// Handle ES6 modules using default export for the transform
	const transform = module.default ? module.default : module;

	// Jest resets the module registry after each test, so we need to always get
	// a fresh copy of jscodeshift on every test run.
	let jscodeshift = require("jscodeshift/dist/core");
	if (module.parser) {
		jscodeshift = jscodeshift.withParser(module.parser);
	}
	const ast = jscodeshift(source);
	if (initOptions || typeof initOptions === "boolean") {
		return transform(jscodeshift, ast, initOptions, action).toSource({
			quote: "single"
		});
	}
	return transform(jscodeshift, ast, source, action).toSource({
		quote: "single"
	});
}

/**
 * Handles some boilerplate around defining a simple jest/Jasmine test for a
 * jscodeshift transform.
 * @param  {String} dirName          contains the name of the directory the test is located in. This
 *                                   should normally be passed via __dirname.
 * @param  {String} transformName    contains the filename of the transform being tested,
 *                                   excluding the .js extension.
 * @param  {String} [testFilePrefix] Optionally contains the name of the file with the test
 *                                   data. If not specified, it defaults to the same value as `transformName`.
 *                                   This will be suffixed with ".input.js" for the input file and ".output.js"
 *                                   for the expected output. For example, if set to "foo", we will read the
 *                                   "foo.input.js" file, pass this to the transform, and expect its output to
 *                                   be equal to the contents of "foo.output.js".
 * @param  {any} transformObject     Object to be transformed with the transformations
 * @param  {String} action init, update or remove, decides how to format the AST
 * @return {Void} Jest makes sure to execute the globally defined functions
 */
function defineTest(
	dirName,
	transformName,
	testFilePrefix,
	transformObject,
	action
) {
	const testName = testFilePrefix
		? `transforms correctly using "${testFilePrefix}" data`
		: "transforms correctly";
	describe(transformName, () => {
		it(testName, () => {
			const output = runSingleTransform(
				dirName,
				transformName,
				testFilePrefix,
				transformObject,
				action
			);
			expect(output).toMatchSnapshot();
		});
	});
}
module.exports = defineTest;

Anon7 - 2022
AnonSec Team