// List of string literals of slow tests with duration comments. function getLiteralsForSlow(leadingComment, slowList) { const result = slowList.map(([path, duration]) => { const literal = babelTypes.stringLiteral(path); babelTypes.addComment( literal, 'trailing', ` ${duration / 1000}s`, true); return literal; }); if (result.length) { babelTypes.addComment(result[0], 'leading', leadingComment); } return result; }
/** * Create print statements for printing the magic section prefix that's * expected by v8_foozzie.py to differentiate different source files. */ getSectionHeader(path) { const orig = common.getOriginalPath(path.node); return printValue({ VALUE: babelTypes.stringLiteral(SECTION_PREFIX + orig), }); }
generateEl(isChildren = true, isFirst = false) { const propertyArray = [t.objectProperty(t.identifier('path'), t.stringLiteral(`${isChildren ? (isFirst ? '' : this.toLowerLine(this.argv.componentName)) : (isFirst ? '/' : '/' + this.toLowerLine(this.argv.componentName))}`)), t.objectProperty(t.identifier('component'), t.identifier(this.argv.ComponentName))]; if (this.argv.metaParam) { propertyArray.push(t.objectProperty(t.identifier('meta'), t.stringLiteral(this.argv.metaParam)), t.objectProperty(t.identifier('name'), t.stringLiteral(this.argv.componentName))); } return t.objectExpression(propertyArray); }
const fileMetaGenerator = (meta) => { const { path, mocks, } = meta; return t.objectExpression([ t.objectProperty(t.identifier('path'), t.stringLiteral(path)), t.objectProperty(t.identifier('mocks'), t.arrayExpression(mocks.map(mock => t.stringLiteral(mock)))), ]); }
const makeStyledJsxCss = (transformedCss, isTemplateLiteral) => { if (!isTemplateLiteral) { return t.stringLiteral(transformedCss); } // Build the expression from transformedCss let css; traverse(parse(`\`${transformedCss}\``), { TemplateLiteral(path) { if (!css) { css = path.node; } }, }); return css; }
/** * Turn the key of an object property into a string literal. */ function keyToString(key) { if (babelTypes.isNumericLiteral(key)) { return babelTypes.stringLiteral(key.value.toString()); } if (babelTypes.isIdentifier(key)) { return babelTypes.stringLiteral(key.name); } // Already a string literal. return key; }
function maybeAddImportStatement(path) { if (this.validFunctions.length || this.atLeastOneRecorderWrapperUsed) { const recorderImportStatement = buildRequire({ SOURCE: t.stringLiteral(this.importPath), IDENTIFIER: t.identifier('recorderWrapper'), }); path.unshiftContainer('body', recorderImportStatement); } if (this.atLeastOneMockUsed) { const recorderImportStatement = buildRequire({ SOURCE: t.stringLiteral(this.importPath), IDENTIFIER: t.identifier('mockRecorderWrapper'), }); path.unshiftContainer('body', recorderImportStatement); } const recorderImportStatement = buildRequire({ SOURCE: t.stringLiteral(this.importPath), IDENTIFIER: t.identifier('recordFileMeta'), }); path.unshiftContainer('body', recorderImportStatement); }
"void", t.callExpression(t.identifier("require"), [ t.stringLiteral(`./${basename(outFile)}`), ]) );
const metaGenerator = (path, funObj) => { const { name, isAsync, paramIds, isDefault, isEcmaDefault, injectionWhitelist, isObject, } = funObj; return t.objectExpression([ t.objectProperty(t.identifier('path'), t.stringLiteral(path)), t.objectProperty(t.identifier('name'), t.stringLiteral(name)), // t.objectProperty(t.identifier('localName'), t.stringLiteral(localName)), t.objectProperty(t.identifier('paramIds'), t.arrayExpression(paramIds.map(pid => t.stringLiteral(pid)))), t.objectProperty(t.identifier('injectionWhitelist'), t.arrayExpression(injectionWhitelist.map(wl => t.stringLiteral(wl)))), t.objectProperty(t.identifier('isDefault'), t.booleanLiteral(isDefault)), t.objectProperty(t.identifier('isEcmaDefault'), t.booleanLiteral(isEcmaDefault)), t.objectProperty(t.identifier('isAsync'), t.booleanLiteral(isAsync)), t.objectProperty(t.identifier('isObject'), t.booleanLiteral(isObject)), ]); }
// List of string literals of failed tests. function getLiteralsForFailed(leadingComment, failedList) { const result = failedList.map(path => babelTypes.stringLiteral(path)); if (result.length) { babelTypes.addComment(result[0], 'leading', leadingComment); } return result; }
t.callExpression(t.identifier("customSetVal"), [ stateSetter, t.stringLiteral(componentName), t.stringLiteral(stateName) ])
const mockInjectorGenerator = ( moduleId, moduleName, importId, importedAs, newFunctionName, fileName, isObjectLike, ) => { if (isObjectLike) { return mockInjectorObjLike({ FP_ID: t.identifier(importedAs), NEW_FP_ID: t.identifier(newFunctionName), FP_STRING_LITERAL: t.stringLiteral(importedAs), MODULE_ID: t.identifier(moduleId), MODULE_STRING_LITERAL: t.stringLiteral(moduleName), FILE_NAME: t.stringLiteral(fileName), }); } return mockInjector({ FP_ID: t.identifier(importedAs), NEW_FP_ID: t.identifier(newFunctionName), FP_STRING_LITERAL: t.stringLiteral(importId), // MODULE_ID: t.identifier(moduleId), MODULE_STRING_LITERAL: t.stringLiteral(moduleName), FILE_NAME: t.stringLiteral(fileName), }); }