@joystick.js/test-canary 0.0.0-canary.65 → 0.0.0-canary.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{parseHTML as m}from"linkedom";import w from"@joystick.js/ui-canary";import d from"node-fetch";import{URL as p,URLSearchParams as u}from"url";import
|
|
1
|
+
import{parseHTML as m}from"linkedom";import w from"@joystick.js/ui-canary";import d from"node-fetch";import{URL as p,URLSearchParams as u}from"url";import h from"./event.js";import _ from"../load/index.js";const g=()=>{const t=m(`
|
|
2
2
|
<html>
|
|
3
3
|
<head></head>
|
|
4
4
|
<body>
|
|
@@ -6,4 +6,4 @@ import{parseHTML as m}from"linkedom";import w from"@joystick.js/ui-canary";impor
|
|
|
6
6
|
<meta name="csrf" content="joystick_test" />
|
|
7
7
|
</body>
|
|
8
8
|
</html>
|
|
9
|
-
`),{window:
|
|
9
|
+
`),{window:c,document:e,Element:s,Event:n,HTMLElement:l}=t;return global.window=c,global.document=e,global.HTMLElement=l,global.Element=s,global.Event=n,global.console={log:console.log,warn:console.warn,error:console.error},t};var T=async(t="",c={})=>{const e=g();window.fetch=d,window.location={origin:`http://localhost:${process.env.PORT}`};const s=new p(`${window?.location?.origin}/api/_test/bootstrap`);s.search=new u({pathToComponent:t});const n=await d(s).then(async o=>o.json());console.log(n),window.joystick={},window.__joystick_data__=n?.data||{},window.__joystick_i18n__=n?.translations||{},window.__joystick_req__={params:{},query:{},context:{user:{}}};const l=await _(t,{default:!0}),r=w.mount(l,c?.props||{},e?.document.querySelector("#app"));return r.isTest=!0,{dom:e,instance:r,test:{data:async(o={})=>r?.data?.refetch(o),render:()=>{const o=r?.renderToHTML(),a=new RegExp("<when>|</when>","g");return o?.wrapped?.replace(a,"")},method:(o="",...a)=>{const i=r?.methods[o];return i?i(...a):null},event:(o="",a="")=>h(o,a,e)}}};export{T as default};
|
package/package.json
CHANGED
|
@@ -82,7 +82,9 @@ export default async (pathToComponent = '', options = {}) => {
|
|
|
82
82
|
return component?.data?.refetch(input);
|
|
83
83
|
},
|
|
84
84
|
render: () => {
|
|
85
|
-
|
|
85
|
+
const html = component?.renderToHTML();
|
|
86
|
+
const whenRegex = new RegExp('<when>|</when>', 'g');
|
|
87
|
+
return html?.wrapped?.replace(whenRegex, '');
|
|
86
88
|
},
|
|
87
89
|
method: (methodName = '', ...methodArgs) => {
|
|
88
90
|
const methodToCall = component?.methods[methodName];
|