Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@suitest/smst

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@suitest/smst - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

6

commonjs/jsxFactory.d.ts
/// <reference path="../types/intrinsicElements.d.ts" />
import { CodeBlockNode, ConditionNode, Node, SingleNode, TestLineNode, TextNode } from '../types/unistTestLine';
import { Node } from '../types/unistTestLine';
declare type DeepArrayOrOne<T> = T | Array<T | DeepArrayOrOne<T>>;

@@ -13,5 +13,3 @@ export declare const flatten: <T extends any>(input: DeepArrayOrOne<T>) => T[];

*/
export declare const jsx: (type: "text" | "subject" | "input" | "code" | "code-block" | "prop" | "props" | "condition" | "test-line" | "test-line-result" | "fragment", props: {
[key: string]: any;
} | null, ...children: (string | TextNode | import("../types/unistTestLine").SubjectNode | import("../types/unistTestLine").InputNode | import("../types/unistTestLine").CodeNode | CodeBlockNode | import("../types/unistTestLine").InlinePropertyNode | import("../types/unistTestLine").CodePropertyNode | import("../types/unistTestLine").PropertiesNode | ConditionNode | TestLineNode | import("../types/unistTestLine").TestLineResultNode | SingleNode[])[]) => Node;
export declare function jsx<K extends keyof JSX.ElementsProps>(type: K, props: JSX.ElementsProps[K], ...children: Array<JSX.ElementsChildren[K]>): Node;
export {};

@@ -10,3 +10,5 @@ "use strict";

var plainTypes = ['text', 'code', 'subject', 'input'];
var isTextNode = function (input) { return !!input && plainTypes.includes(input.type); };
var isTextNode = function (input) {
return typeof input === 'object' && input !== null && plainTypes.includes(input.type);
};
exports.flatten = function (input) {

@@ -18,11 +20,11 @@ if (Array.isArray(input)) {

};
/**
* Normalize textual children - make them flat and merge sequential text items of same type
*/
var normalizePlainChildren = function (children, parentType) {
function normalizePlainChildren(children, parentType) {
return children.reduce(function (output, child) {
var _a;
if (typeof child === 'string') {
if (child === undefined || child === null) {
return output;
}
if (typeof child === 'string' || typeof child === 'boolean' || typeof child === 'number') {
// Wrap plain strings into text nodes
child = unist_builder_1.default(plainTypes.includes(parentType) ? parentType : 'text', child);
child = unist_builder_1.default(plainTypes.includes(parentType) ? parentType : 'text', String(child));
}

@@ -43,8 +45,8 @@ // Nested child is a textual node

}, []);
};
var processLabel = function (label) {
}
var processTextNode = function (label) {
return normalizePlainChildren(exports.flatten([label]), 'text');
};
var processPropertyNode = function (props) {
var name = processLabel(props.name);
var name = processTextNode(props.name);
if (isCodeBlockNode(props.expectedValue)) {

@@ -62,3 +64,3 @@ return unist_builder_1.default('prop', {

contentType: 'inline',
expectedValue: processLabel(props.expectedValue),
expectedValue: processTextNode(props.expectedValue),
actualValue: props.actualValue,

@@ -72,3 +74,5 @@ comparator: props.comparator,

};
var isCodeBlockNode = function (item) { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.type) === 'code-block'; };
var isCodeBlockNode = function (item) {
return !Array.isArray(item) && typeof item === 'object' && item !== null && item.type === 'code-block';
};
var isTestLineNodeArray = function (children) {

@@ -89,9 +93,3 @@ return children.every(function (child) { return child.type === 'test-line'; });

};
/**
* A factory for JSX elements. Maps React-style JSX to unist-style nodes.
* "any" is used for children and props because TypeScript can't infer JSX element types
* anyway and always returns whatever is provided in JSX.Element type/interface.
* Some validation is added to ensure correct data at least runtime.
*/
exports.jsx = function (type, props) {
function jsx(type, props) {
var children = [];

@@ -101,6 +99,6 @@ for (var _i = 2; _i < arguments.length; _i++) {

}
var _a, _b, _c, _d, _e;
var _a, _b;
// Do not include empty children, to allow for ternary operations in JSX
// Flatten the children - to support nested arrays in JSX and manage fragments
var processedChildren = normalizePlainChildren(exports.flatten(children.filter(function (child) { return typeof child !== 'undefined' && child !== null; })), type);
var processedChildren = normalizePlainChildren(exports.flatten(children), type);
switch (type) {

@@ -115,5 +113,7 @@ case 'text':

case 'code-block':
var language = (_b = (_a = props) === null || _a === void 0 ? void 0 : _a.language, (_b !== null && _b !== void 0 ? _b : 'javascript'));
var codeBlockProps = props;
var codeBlockChildren = processedChildren[0];
var language = (_b = (_a = codeBlockProps) === null || _a === void 0 ? void 0 : _a.language, (_b !== null && _b !== void 0 ? _b : 'javascript'));
// Type casting because IntrinsicElements definition would not allow anything other then string
return unist_builder_1.default('code-block', { language: language }, processedChildren[0].value);
return unist_builder_1.default('code-block', { language: language }, codeBlockChildren.value);
case 'prop':

@@ -129,15 +129,18 @@ // props can't be null because it's defined in intrinsicElements

case 'test-line':
var testLineProps = props;
// Type casting for props because of IntrinsicElements definition
var params = {
title: processLabel(props.title),
title: processTextNode(testLineProps.title),
};
if ((_c = props) === null || _c === void 0 ? void 0 : _c.status) {
params.status = props.status;
if (testLineProps.status) {
params.status = testLineProps.status;
}
return unist_builder_1.default(type, params, processedChildren);
case 'test-line-result':
var testLineResultProps = props;
if (isTestLineNodeArray(processedChildren) && processedChildren.length === 1) {
return unist_builder_1.default('test-line-result', {
status: (_d = props) === null || _d === void 0 ? void 0 : _d.status,
message: processLabel((_e = props) === null || _e === void 0 ? void 0 : _e.message),
status: testLineResultProps.status,
message: processTextNode(testLineResultProps.message),
screenshot: testLineResultProps.screenshot,
}, processedChildren);

@@ -150,3 +153,4 @@ }

}
};
}
exports.jsx = jsx;
//# sourceMappingURL=jsxFactory.js.map
{
"name": "@suitest/smst",
"version": "3.0.1",
"version": "3.0.2",
"description": "UNIST definition and JSX factory for Suitest test lines rendering",

@@ -5,0 +5,0 @@ "repository": {

@@ -162,3 +162,4 @@ # SMST

children: TestLine
message: [Paragraph]
message: [Paragraph],
screenhost: [string],
}

@@ -165,0 +166,0 @@ ```

@@ -6,4 +6,2 @@ type SingleNode = import('./unistTestLine').SingleNode;

type TestLineResultStatus = import('./unistTestLine').TestLineResultStatus;
type ElementOrTextChildren = string | SingleNode | undefined | ElementOrTextChildren[];
type ElementChildren = SingleNode | undefined | ElementChildren[];
type StringOrStrings = string | string[];

@@ -20,4 +18,11 @@

// https://www.typescriptlang.org/docs/handbook/jsx.html#the-jsx-result-type
type Element = Node;
// type Element = SingleElement | Element[];
type Element = SingleNode;
type SmstText = string | number;
type SmstChild = Node | string | number;
type SmstElement = SmstChild | boolean | null | undefined;
type SmstNode = SmstElement | SmstElement[];
type SmstFlatNode = SingleNode | SmstText | boolean | null | undefined;
interface IntrinsicElements {

@@ -30,3 +35,3 @@ // Plain text, should accept only string or other textual elements to make

code: {children: StringOrStrings},
fragment: {children: ElementOrTextChildren},
fragment: {children: SmstNode},
'code-block': {

@@ -37,17 +42,17 @@ children: StringOrStrings,

prop: {
name: ElementChildren,
name: SmstNode,
comparator?: string,
expectedValue: ElementChildren,
expectedValue: SmstNode,
actualValue?: string | number,
status?: SingleEntryStatus,
},
props: {children: ElementChildren},
props: {children: SmstNode},
condition: {
title: ElementChildren,
children?: ElementChildren,
title: SmstNode,
children?: SmstNode,
status?: SingleEntryStatus,
},
'test-line': {
title: ElementChildren,
children?: ElementChildren,
title: SmstNode,
children?: SmstNode,
status?: TestLineResultStatus,

@@ -57,6 +62,35 @@ },

status: TestLineResultStatus,
children: ElementChildren,
message?: ElementChildren,
children: SmstNode,
message?: SmstNode,
screenshot?: string,
},
}
type ElementsProps = {
text: Omit<IntrinsicElements['text'], 'children'>,
subject: Omit<IntrinsicElements['subject'], 'children'>,
input: Omit<IntrinsicElements['input'], 'children'>,
code: Omit<IntrinsicElements['code'], 'children'>,
fragment: Omit<IntrinsicElements['fragment'], 'children'>,
'code-block': Omit<IntrinsicElements['code-block'], 'children'> | null,
prop: IntrinsicElements['prop'],
props: Omit<IntrinsicElements['props'], 'children'>,
condition: Omit<IntrinsicElements['condition'], 'children'>,
'test-line': Omit<IntrinsicElements['test-line'], 'children'>,
'test-line-result': Omit<IntrinsicElements['test-line-result'], 'children'>,
};
type ElementsChildren = {
text: IntrinsicElements['text']['children'],
subject: IntrinsicElements['subject']['children'],
input: IntrinsicElements['input']['children'],
code: IntrinsicElements['code']['children'],
fragment: IntrinsicElements['fragment']['children'],
'code-block': IntrinsicElements['code-block']['children'],
prop: void,
props: IntrinsicElements['props']['children'],
condition: IntrinsicElements['condition']['children'],
'test-line': IntrinsicElements['test-line']['children'],
'test-line-result': IntrinsicElements['test-line-result']['children'],
};
}

@@ -80,2 +80,3 @@ export type TextNode = {

message?: InlineTextNode[],
screenshot?: string,
};

@@ -82,0 +83,0 @@

/// <reference path="../types/intrinsicElements.d.ts" />
import { CodeBlockNode, ConditionNode, Node, SingleNode, TestLineNode, TextNode } from '../types/unistTestLine';
import { Node } from '../types/unistTestLine';
declare type DeepArrayOrOne<T> = T | Array<T | DeepArrayOrOne<T>>;

@@ -13,5 +13,3 @@ export declare const flatten: <T extends any>(input: DeepArrayOrOne<T>) => T[];

*/
export declare const jsx: (type: "text" | "subject" | "input" | "code" | "code-block" | "prop" | "props" | "condition" | "test-line" | "test-line-result" | "fragment", props: {
[key: string]: any;
} | null, ...children: (string | TextNode | import("../types/unistTestLine").SubjectNode | import("../types/unistTestLine").InputNode | import("../types/unistTestLine").CodeNode | CodeBlockNode | import("../types/unistTestLine").InlinePropertyNode | import("../types/unistTestLine").CodePropertyNode | import("../types/unistTestLine").PropertiesNode | ConditionNode | TestLineNode | import("../types/unistTestLine").TestLineResultNode | SingleNode[])[]) => Node;
export declare function jsx<K extends keyof JSX.ElementsProps>(type: K, props: JSX.ElementsProps[K], ...children: Array<JSX.ElementsChildren[K]>): Node;
export {};

@@ -19,3 +19,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {

var plainTypes = ['text', 'code', 'subject', 'input'];
var isTextNode = function (input) { return !!input && plainTypes.includes(input.type); };
var isTextNode = function (input) {
return typeof input === 'object' && input !== null && plainTypes.includes(input.type);
};
exports.flatten = function (input) {

@@ -27,11 +29,11 @@ if (Array.isArray(input)) {

};
/**
* Normalize textual children - make them flat and merge sequential text items of same type
*/
var normalizePlainChildren = function (children, parentType) {
function normalizePlainChildren(children, parentType) {
return children.reduce(function (output, child) {
var _a;
if (typeof child === 'string') {
if (child === undefined || child === null) {
return output;
}
if (typeof child === 'string' || typeof child === 'boolean' || typeof child === 'number') {
// Wrap plain strings into text nodes
child = unist_builder_1.default(plainTypes.includes(parentType) ? parentType : 'text', child);
child = unist_builder_1.default(plainTypes.includes(parentType) ? parentType : 'text', String(child));
}

@@ -52,8 +54,8 @@ // Nested child is a textual node

}, []);
};
var processLabel = function (label) {
}
var processTextNode = function (label) {
return normalizePlainChildren(exports.flatten([label]), 'text');
};
var processPropertyNode = function (props) {
var name = processLabel(props.name);
var name = processTextNode(props.name);
if (isCodeBlockNode(props.expectedValue)) {

@@ -71,3 +73,3 @@ return unist_builder_1.default('prop', {

contentType: 'inline',
expectedValue: processLabel(props.expectedValue),
expectedValue: processTextNode(props.expectedValue),
actualValue: props.actualValue,

@@ -81,3 +83,5 @@ comparator: props.comparator,

};
var isCodeBlockNode = function (item) { var _a; return ((_a = item) === null || _a === void 0 ? void 0 : _a.type) === 'code-block'; };
var isCodeBlockNode = function (item) {
return !Array.isArray(item) && typeof item === 'object' && item !== null && item.type === 'code-block';
};
var isTestLineNodeArray = function (children) {

@@ -98,9 +102,3 @@ return children.every(function (child) { return child.type === 'test-line'; });

};
/**
* A factory for JSX elements. Maps React-style JSX to unist-style nodes.
* "any" is used for children and props because TypeScript can't infer JSX element types
* anyway and always returns whatever is provided in JSX.Element type/interface.
* Some validation is added to ensure correct data at least runtime.
*/
exports.jsx = function (type, props) {
function jsx(type, props) {
var children = [];

@@ -110,6 +108,6 @@ for (var _i = 2; _i < arguments.length; _i++) {

}
var _a, _b, _c, _d, _e;
var _a, _b;
// Do not include empty children, to allow for ternary operations in JSX
// Flatten the children - to support nested arrays in JSX and manage fragments
var processedChildren = normalizePlainChildren(exports.flatten(children.filter(function (child) { return typeof child !== 'undefined' && child !== null; })), type);
var processedChildren = normalizePlainChildren(exports.flatten(children), type);
switch (type) {

@@ -124,5 +122,7 @@ case 'text':

case 'code-block':
var language = (_b = (_a = props) === null || _a === void 0 ? void 0 : _a.language, (_b !== null && _b !== void 0 ? _b : 'javascript'));
var codeBlockProps = props;
var codeBlockChildren = processedChildren[0];
var language = (_b = (_a = codeBlockProps) === null || _a === void 0 ? void 0 : _a.language, (_b !== null && _b !== void 0 ? _b : 'javascript'));
// Type casting because IntrinsicElements definition would not allow anything other then string
return unist_builder_1.default('code-block', { language: language }, processedChildren[0].value);
return unist_builder_1.default('code-block', { language: language }, codeBlockChildren.value);
case 'prop':

@@ -138,15 +138,18 @@ // props can't be null because it's defined in intrinsicElements

case 'test-line':
var testLineProps = props;
// Type casting for props because of IntrinsicElements definition
var params = {
title: processLabel(props.title),
title: processTextNode(testLineProps.title),
};
if ((_c = props) === null || _c === void 0 ? void 0 : _c.status) {
params.status = props.status;
if (testLineProps.status) {
params.status = testLineProps.status;
}
return unist_builder_1.default(type, params, processedChildren);
case 'test-line-result':
var testLineResultProps = props;
if (isTestLineNodeArray(processedChildren) && processedChildren.length === 1) {
return unist_builder_1.default('test-line-result', {
status: (_d = props) === null || _d === void 0 ? void 0 : _d.status,
message: processLabel((_e = props) === null || _e === void 0 ? void 0 : _e.message),
status: testLineResultProps.status,
message: processTextNode(testLineResultProps.message),
screenshot: testLineResultProps.screenshot,
}, processedChildren);

@@ -159,4 +162,5 @@ }

}
};
}
exports.jsx = jsx;
});
//# sourceMappingURL=jsxFactory.js.map

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc