You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@awsui/test-utils-converter

Package Overview
Dependencies
Maintainers
3
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@awsui/test-utils-converter - npm Package Compare versions

Comparing version

to
1.0.29

dist/convert-to-selectors.d.ts

3

dist/index.d.ts

@@ -1,1 +0,2 @@

export default function convertToSelectorUtil(source: string): string | null | undefined;
export { convertToSelectorUtil as default } from './convert-to-selectors';
export { extractTestSelectorsUtil } from './extract-test-selectors';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
const core_1 = require("@babel/core");
const runtimeSelectorsPath = `@awsui/test-utils-core/selectors`;
const ourWrappers = ['ElementWrapper', 'ComponentWrapper'];
function selectorUtilsGenerator({ types: t }) {
return {
visitor: {
ImportDeclaration(path) {
const source = path.get('source');
// Rewrite import path @awsui/.../dom -> @awsui/.../selectors
if (source.node.value.startsWith('@awsui/')) {
const newImportPath = source.node.value.replace(/\b\/dom\b/, '/selectors');
source.replaceWith(t.stringLiteral(newImportPath));
}
// Remove @usesDom decorator
if (source.node.value === runtimeSelectorsPath) {
path
.get('specifiers')
.filter(spec => spec.node.local.name === 'usesDom')
.forEach(spec => spec.remove());
}
},
ClassDeclaration(path) {
var _a;
// our wrapper classes have generic parameters only in DOM version
if (ourWrappers.includes((_a = path.node.superClass) === null || _a === void 0 ? void 0 : _a.name) && path.node.superTypeParameters) {
path.node.superTypeParameters = null;
}
},
ClassMethod(path) {
const decorators = path.node.decorators;
// remove methods marked with @usesDom decorator
if (decorators) {
const domDecorator = decorators.find(dec => t.isIdentifier(dec.expression) && dec.expression.name === 'usesDom');
if (domDecorator) {
path.remove();
return;
}
}
// Remove explicit return types, let Typescript infer them
path.get('returnType').remove();
},
TSTypeParameterInstantiation(path) {
// Remove all DOM-types, they are not needed in selectors
const containsDomElement = path.node.params.some(param => param.type === 'TSTypeReference' &&
param.typeName.type === 'Identifier' &&
param.typeName.name.startsWith('HTML'));
if (containsDomElement) {
path.remove();
}
},
},
};
}
function convertToSelectorUtil(source) {
var _a;
return (_a = (0, core_1.transformSync)(source, {
babelrc: false,
configFile: false,
plugins: [
require('@babel/plugin-syntax-typescript'),
[require('@babel/plugin-syntax-decorators'), { legacy: true }],
selectorUtilsGenerator,
],
})) === null || _a === void 0 ? void 0 : _a.code;
}
exports.default = convertToSelectorUtil;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractTestSelectorsUtil = exports.default = void 0;
var convert_to_selectors_1 = require("./convert-to-selectors");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return convert_to_selectors_1.convertToSelectorUtil; } });
var extract_test_selectors_1 = require("./extract-test-selectors");
Object.defineProperty(exports, "extractTestSelectorsUtil", { enumerable: true, get: function () { return extract_test_selectors_1.extractTestSelectorsUtil; } });
{
"commit": "50b7d139682f1b7bea06c2697b4b769ca5915aef"
"commit": "0296cabae4dfb3589c5556cb0e605d5464f552b4"
}

@@ -1,1 +0,1 @@

{"name":"@awsui/test-utils-converter","version":"1.0.28","homepage":"https://github.com/aws/awsui-documentation","main":"dist/index.js","files":["dist","internal"],"dependencies":{"@babel/core":"^7.16.0","@babel/plugin-syntax-decorators":"^7.16.0","@babel/plugin-syntax-typescript":"^7.16.0"},"jest":{"preset":"ts-jest","globals":{"ts-jest":{"tsconfig":"test/tsconfig.json"}}},"license":"Apache-2.0"}
{"name":"@awsui/test-utils-converter","version":"1.0.29","homepage":"https://github.com/aws/awsui-documentation","main":"dist/index.js","files":["dist","internal"],"dependencies":{"@babel/core":"^7.16.0","@babel/plugin-syntax-decorators":"^7.16.0","@babel/plugin-syntax-typescript":"^7.16.0","glob":"^7.2.0"},"jest":{"preset":"ts-jest","globals":{"ts-jest":{"tsconfig":"test/tsconfig.json"}}},"license":"Apache-2.0"}