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

@suitest/smst-to-text

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@suitest/smst-to-text - npm Package Compare versions

Comparing version 4.2.2 to 4.4.3

LICENSE

2

dist/toText.js

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

"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i},__values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},__spread=this&&this.__spread||function(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(__read(arguments[r]));return e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toText=exports.wrapTextNodes=exports.escapeControlChars=void 0;var smst_1=require("@suitest/smst"),nl="\n",tab=" ",emptyString="[EMPTY STRING]",notDefined="[NOT DEFINED]",controlChars=new RegExp([[0,8],[11,12],[14,31],[127,159]].map((function(e){var r=__read(e,2),t=r[0],n=r[1];return"["+String.fromCharCode(t)+"-"+String.fromCharCode(n)+"]"})).join("|"),"g"),formatNotDefined=function(e,r){return void 0===r&&(r=String),null==e?notDefined:""===e?emptyString:r(e)};exports.escapeControlChars=function(e){return e.replace(controlChars,"�")};var format={cancel:"",subject:"",code:"",input:"",success:"",fail:"",fatal:"",warning:"",exit:"",excluded:"",aborted:""},formatString=function(e,r){return r in format?format[r]+e+format.cancel:e},calcPureLength=function(e){return Object.values(format).reduce((function(e,r){return e.replace(r,"")}),e).length},wrapText=function(e,r,t){void 0===r&&(r=115),void 0===t&&(t=0);var n=0===t?"":" ".repeat(t);return e.length>r?e.split(/\s/).reduce((function(e,o){var a=1===e.length?r-t:r,i=e[e.length-1],s=calcPureLength(i);if(s+calcPureLength(o)+1>a+5){if(s>=a-5)return e.push(n+o),e;var l=o.slice(0,a-s),u=o.slice(a-s);return e[e.length-1]=i+" "+l,e.push(n+u),e}return e[e.length-1]=(i?i+" ":"")+o,e}),[""]).join(nl):e},renderPlainTextNode=function(e){return(null==e?void 0:e.value)?exports.escapeControlChars(e.value):""},renderFormattedTextNode=function(e){return(null==e?void 0:e.value)?formatString(exports.escapeControlChars(e.value),e.type):""},renderStatus=function(e){var r="";switch(e){case"success":r="✔ ";break;case"fail":case"fatal":r="✖ ";break;case"warning":r="‼ ";break;case"excluded":case"exit":r="» ";break;case"aborted":r="⦻ "}return{type:e,value:r}},splitNode=function(e,r){return[__assign(__assign({},e),{value:e.value.slice(0,r)}),__assign(__assign({},e),{value:e.value.slice(r)})]};exports.wrapTextNodes=function(e,r,t){var n,o;void 0===t&&(t=60);var a=[];try{for(var i=__values(e),s=i.next();!s.done;s=i.next()){var l=s.value,u=l.value.split(/\r\n|\r|\n/);if(1===u.length)a.push(l);else for(var c=0;c<u.length;c++)0!==c&&a.push({type:"newline"}),a.push({type:l.type,value:u[c]})}}catch(e){n={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}for(var d=[""],p=0,f=0,v=a.shift();v;){if("newline"===v.type)f=0,d.push("");else if(v.value.length<=t-f)f+=v.value.length,d[d.length-1]+=r(v),p=f>p?f:p;else{var h=splitNode(v,t-f);f=0,d[d.length-1]+=r(h[0]),d.push(""),a.splice(0,0,h[1]),p=t}v=a.shift()}return[p,d]};var renderProps=function(e,r,t){var n,o,a,i,s,l,u,c=t.prefix,d=void 0===c?"":c,p=t.verbosity,f=[0,0,0],v=[];try{for(var h=__values(e.children),y=h.next();!y.done;y=h.next()){var m=y.value,x=[];v.push(x);var g=__spread(m.name);m.status&&g.splice(0,0,renderStatus(m.status));var _=__read(exports.wrapTextNodes(g,r),2),b=_[0],w=_[1];x.push(w),b>f[0]&&(f[0]=b);var T=null!==(l=null===(s=m.comparator)||void 0===s?void 0:s.length)&&void 0!==l?l:0;if(x.push([null!==(u=m.comparator)&&void 0!==u?u:""]),T>f[1]&&(f[1]=T),"block"===m.contentType)x=[],v.push(x),x.push(renderNode(m.expectedValue,r,{prefix:tab,verbosity:p}).split(nl));else{var N=exports.wrapTextNodes(m.expectedValue,r);0===N[0]?(x.push([emptyString]),N[0]=emptyString.length):x.push(N[1]),N[0]>f[2]&&(f[2]=N[0])}if("inline"===m.contentType&&void 0!==m.actualValue){x=[],v.push(x),x.push([],["→"]),0===f[1]&&(f[1]=1);var S=__read(exports.wrapTextNodes([{type:"text",value:formatNotDefined(m.actualValue)}],r),2),j=S[0],C=S[1];x.push(C),j>f[2]&&(f[2]=j)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}var P=[];try{for(var L=__values(v),O=L.next();!O.done;O=L.next())for(var k=O.value;k.some((function(e){return e.length}));)P.push(d+k.map((function(e,r){var t,n=null!==(t=e.shift())&&void 0!==t?t:"",o=calcPureLength(n);return o<f[r]&&(n+=" ".repeat(f[r]-o)),n[1===r?"padStart":"padEnd"](f[r])})).join(" "))}catch(e){a={error:e}}finally{try{O&&!O.done&&(i=L.return)&&i.call(L)}finally{if(a)throw a.error}}return P.join(nl)},renderNode=function(e,r,t){var n=t.prefix,o=void 0===n?"":n,a=t.verbosity;switch(e.type){case"text":case"code":case"subject":case"input":return r(e);case"props":return renderProps(e,r,{prefix:o,verbosity:a});case"prop":throw new Error("Prop node can only be rendered as part of Props");case"code-block":return formatNotDefined(e.value,(function(e){return e.split(nl).map((function(e){return o+"> "+e})).join(nl)}));case"test-line":case"condition":return renderTestLineOrCondition(e,r,{prefix:o,verbosity:a});case"test-line-result":return renderTestLineResult(e,r,{prefix:o,verbosity:a});case"link":return e.value!==e.href&&e.value?e.value+" ("+e.href+")":e.href;default:return smst_1.assertUnknownSectionNode(e)}},renderTestLineOrCondition=function(e,r,t){var n=t.prefix,o=void 0===n?"":n,a=t.verbosity,i=e.status?r(renderStatus(e.status)):"",s=e.title.map(r).join(""),l=e.children.map((function(e){return renderNode(e,r,{prefix:o+tab,verbosity:a})})).join(""),u=[o+i+s];return"normal"!==a&&"verbose"!==a||u.push(l),u.filter(Boolean).join(nl)},renderTestLineResult=function(e,r,t){var n,o=tab+r({type:e.status,value:e.status+": "}),a="";if("excluded"===e.status)a=o+"Test line was not executed";else{var i=null===(n=e.message)||void 0===n?void 0:n.map(r).join("");i&&(a=o+wrapText(i,void 0,calcPureLength(o)))}var s=renderTestLineOrCondition(e.children[0],r,t),l=e.screenshot?"screenshot: "+e.screenshot:"";return[s,a,["verbose"===t.verbosity&&e.docs?"docs: "+e.docs:"",l].filter(Boolean).map((function(e){return e.split(nl)})).reduce((function(e,r){return e.concat(r)}),[]).map((function(e){return tab+e})).join(nl)].filter(Boolean).join(nl)};exports.toText=function(e,r){var t,n,o=null!==(t=null==r?void 0:r.format)&&void 0!==t&&t,a=null!==(n=null==r?void 0:r.verbosity)&&void 0!==n?n:"normal",i=o?renderFormattedTextNode:renderPlainTextNode;return Array.isArray(e)||(e=[e]),e.map((function(e){return renderNode(e,i,{verbosity:a})})).join("")};
"use strict";var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var o in r=arguments[t])Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o]);return e}).apply(this,arguments)},__read=this&&this.__read||function(e,r){var t="function"==typeof Symbol&&e[Symbol.iterator];if(!t)return e;var n,o,a=t.call(e),i=[];try{for(;(void 0===r||r-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(t=a.return)&&t.call(a)}finally{if(o)throw o.error}}return i},__values=this&&this.__values||function(e){var r="function"==typeof Symbol&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")},__spread=this&&this.__spread||function(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(__read(arguments[r]));return e};Object.defineProperty(exports,"__esModule",{value:!0}),exports.toText=exports.wrapTextNodes=exports.escapeControlChars=void 0;var smst_1=require("@suitest/smst"),nl="\n",tab=" ",emptyString="[EMPTY STRING]",notDefined="[NOT DEFINED]",controlChars=new RegExp([[0,8],[11,12],[14,31],[127,159]].map((function(e){var r=__read(e,2),t=r[0],n=r[1];return"["+String.fromCharCode(t)+"-"+String.fromCharCode(n)+"]"})).join("|"),"g"),formatNotDefined=function(e,r){return void 0===r&&(r=String),null==e?notDefined:""===e?emptyString:r(e)};exports.escapeControlChars=function(e){return e.replace(controlChars,"�")};var format={cancel:"",subject:"",code:"",input:"",success:"",fail:"",fatal:"",warning:"",exit:"",excluded:"",aborted:""},formatString=function(e,r){return r in format?format[r]+e+format.cancel:e},calcPureLength=function(e){return Object.values(format).reduce((function(e,r){return e.replace(r,"")}),e).length},wrapText=function(e,r,t){void 0===r&&(r=115),void 0===t&&(t=0);var n=0===t?"":" ".repeat(t);return e.length>r?e.split(/\s/).reduce((function(e,o){var a=1===e.length?r-t:r,i=e[e.length-1],s=calcPureLength(i);if(s+calcPureLength(o)+1>a+5){if(s>=a-5)return e.push(n+o),e;var l=o.slice(0,a-s),u=o.slice(a-s);return e[e.length-1]=i+" "+l,e.push(n+u),e}return e[e.length-1]=(i?i+" ":"")+o,e}),[""]).join(nl):e},renderPlainTextNode=function(e){return(null==e?void 0:e.value)?exports.escapeControlChars(e.value):""},renderFormattedTextNode=function(e){return(null==e?void 0:e.value)?formatString(exports.escapeControlChars(e.value),e.type):""},renderStatus=function(e){var r="";switch(e){case"success":r="✔ ";break;case"fail":case"fatal":r="✖ ";break;case"warning":r="‼ ";break;case"excluded":case"exit":r="» ";break;case"aborted":r="⦻ "}return{type:e,value:r}},splitNode=function(e,r){return[__assign(__assign({},e),{value:e.value.slice(0,r)}),__assign(__assign({},e),{value:e.value.slice(r)})]};exports.wrapTextNodes=function(e,r,t){var n,o;void 0===t&&(t=60);var a=[];try{for(var i=__values(e),s=i.next();!s.done;s=i.next()){var l=s.value,u=l.value.split(/\r\n|\r|\n/);if(1===u.length)a.push(l);else for(var c=0;c<u.length;c++)0!==c&&a.push({type:"newline"}),a.push({type:l.type,value:u[c]})}}catch(e){n={error:e}}finally{try{s&&!s.done&&(o=i.return)&&o.call(i)}finally{if(n)throw n.error}}for(var d=[""],p=0,f=0,v=a.shift();v;){if("newline"===v.type)f=0,d.push("");else if(v.value.length<=t-f)f+=v.value.length,d[d.length-1]+=r(v),p=f>p?f:p;else{var h=splitNode(v,t-f);f=0,d[d.length-1]+=r(h[0]),d.push(""),a.splice(0,0,h[1]),p=t}v=a.shift()}return[p,d]};var renderProps=function(e,r,t){var n,o,a,i,s,l,u,c=t.prefix,d=void 0===c?"":c,p=t.verbosity,f=[0,0,0],v=[];try{for(var h=__values(e.children),y=h.next();!y.done;y=h.next()){var m=y.value,x=[];v.push(x);var g=__spread(m.name);m.status&&g.splice(0,0,renderStatus(m.status));var _=__read(exports.wrapTextNodes(g,r),2),b=_[0],w=_[1];x.push(w),b>f[0]&&(f[0]=b);var T=null!==(l=null===(s=m.comparator)||void 0===s?void 0:s.length)&&void 0!==l?l:0;if(x.push([null!==(u=m.comparator)&&void 0!==u?u:""]),T>f[1]&&(f[1]=T),"block"===m.contentType)x=[],v.push(x),x.push(renderNode(m.expectedValue,r,{prefix:tab,verbosity:p}).split(nl));else{var N=exports.wrapTextNodes(m.expectedValue,r);0===N[0]?(x.push([emptyString]),N[0]=emptyString.length):x.push(N[1]),N[0]>f[2]&&(f[2]=N[0])}if("inline"===m.contentType&&void 0!==m.actualValue){x=[],v.push(x),x.push([],["→"]),0===f[1]&&(f[1]=1);var S=__read(exports.wrapTextNodes([{type:"text",value:formatNotDefined(m.actualValue)}],r),2),j=S[0],C=S[1];x.push(C),j>f[2]&&(f[2]=j)}}}catch(e){n={error:e}}finally{try{y&&!y.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}var P=[];try{for(var L=__values(v),O=L.next();!O.done;O=L.next())for(var k=O.value;k.some((function(e){return e.length}));)P.push(d+k.map((function(e,r){var t,n=null!==(t=e.shift())&&void 0!==t?t:"",o=calcPureLength(n);return o<f[r]&&(n+=" ".repeat(f[r]-o)),n[1===r?"padStart":"padEnd"](f[r])})).join(" "))}catch(e){a={error:e}}finally{try{O&&!O.done&&(i=L.return)&&i.call(L)}finally{if(a)throw a.error}}return P.join(nl)},renderNode=function(e,r,t){var n=t.prefix,o=void 0===n?"":n,a=t.verbosity;switch(e.type){case"text":case"code":case"subject":case"input":return r(e);case"props":return renderProps(e,r,{prefix:o,verbosity:a});case"prop":throw new Error("Prop node can only be rendered as part of Props");case"code-block":return formatNotDefined(e.value,(function(e){return e.split(nl).map((function(e){return o+"> "+e})).join(nl)}));case"test-line":case"condition":return renderTestLineOrCondition(e,r,{prefix:o,verbosity:a});case"test-line-result":return renderTestLineResult(e,r,{prefix:o,verbosity:a});case"link":return e.value!==e.href&&e.value?e.value+" ("+e.href+")":e.href;default:return smst_1.assertUnknownSectionNode(e)}},renderTestLineOrCondition=function(e,r,t){var n=t.prefix,o=void 0===n?"":n,a=t.verbosity,i=e.status?r(renderStatus(e.status)):"",s=e.title.map(r).join(""),l=e.children.map((function(e){return renderNode(e,r,{prefix:o+tab,verbosity:a})})).join(""),u=[o+i+s];return"normal"!==a&&"verbose"!==a||u.push(l),u.filter(Boolean).join(nl)},renderTestLineResult=function(e,r,t){var n,o=tab+r({type:e.status,value:e.status+": "}),a="";if("excluded"===e.status)a=o+"Test line was not executed";else{var i=null===(n=e.message)||void 0===n?void 0:n.map((function(e){return renderNode(e,r,t)})).join("");i&&(a=o+wrapText(i,void 0,calcPureLength(o)))}var s=renderTestLineOrCondition(e.children[0],r,t),l=e.screenshot?"screenshot: "+e.screenshot:"";return[s,a,["verbose"===t.verbosity&&e.docs?"docs: "+e.docs:"",l].filter(Boolean).map((function(e){return e.split(nl)})).reduce((function(e,r){return e.concat(r)}),[]).map((function(e){return tab+e})).join(nl)].filter(Boolean).join(nl)};exports.toText=function(e,r){var t,n,o=null!==(t=null==r?void 0:r.format)&&void 0!==t&&t,a=null!==(n=null==r?void 0:r.verbosity)&&void 0!==n?n:"normal",i=o?renderFormattedTextNode:renderPlainTextNode;return Array.isArray(e)||(e=[e]),e.map((function(e){return renderNode(e,i,{verbosity:a})})).join("")};
{
"name": "@suitest/smst-to-text",
"version": "4.2.2",
"version": "4.4.3",
"description": "Utility to convert SMST to plain text or ANSI-styled text",

@@ -33,4 +33,5 @@ "homepage": "https://suite.st/",

"dependencies": {
"@suitest/smst": "^4.2.2"
}
"@suitest/smst": "^4.4.3"
},
"gitHead": "75ec0512ed410119093b33a98464beeba9792dd8"
}
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