@joystick.js/test-canary 0.0.0-canary.71 → 0.0.0-canary.72
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 i}from"linkedom";import d from"@joystick.js/ui-canary";import l from"node-fetch";import{URL as
|
|
1
|
+
import{parseHTML as i}from"linkedom";import d from"@joystick.js/ui-canary";import l from"node-fetch";import{URL as w,URLSearchParams as m}from"url";import p from"./event.js";import h from"../load/index.js";const u=async(e="")=>{const r=new w(`${window?.location?.origin}/api/_test/bootstrap`);r.search=new m({pathToComponent:e});const o=await l(r).then(async a=>a.json());window.joystick={},window.joystick.settings={},window.__joystick_data__=o?.data||{},window.__joystick_i18n__=o?.translations||{},window.__joystick_req__=o?.req,console.log(o)},g=()=>{const e=i(`
|
|
2
2
|
<html>
|
|
3
3
|
<head></head>
|
|
4
4
|
<body>
|
|
@@ -6,4 +6,4 @@ import{parseHTML as i}from"linkedom";import d from"@joystick.js/ui-canary";impor
|
|
|
6
6
|
<meta name="csrf" content="joystick_test" />
|
|
7
7
|
</body>
|
|
8
8
|
</html>
|
|
9
|
-
`),{window:
|
|
9
|
+
`),{window:r,document:o,Element:a,Event:n,HTMLElement:t}=e;return global.window=r,global.document=o,global.HTMLElement=t,global.Element=a,global.Event=n,global.console={log:console.log,warn:console.warn,error:console.error},e};var v=async(e="",r={})=>{const o=g();window.fetch=l,window.location={origin:`http://localhost:${process.env.PORT}`},await u(e);const a=await h(e,{default:!0}),n=d.mount(a,r?.props||{},o?.document.querySelector("#app"));return n.isTest=!0,{dom:o,instance:n,test:{data:async(t={})=>n?.data?.refetch(t),render:()=>{const t=n?.renderToHTML(),s=new RegExp("<when>|</when>","g");return t?.wrapped?.replace(s,"")?.replace(/\n|\t/g," ")?.replace(/> *</g,"><")},method:(t="",...s)=>{const c=n?.methods[t];return c?c(...s):null},event:(t="",s="")=>p(t,s,o)}}};export{v as default};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import { URL, URLSearchParams } from 'url';
|
|
|
6
6
|
import event from './event.js';
|
|
7
7
|
import load from "../load/index.js";
|
|
8
8
|
|
|
9
|
-
const bootstrapWindow = async () => {
|
|
9
|
+
const bootstrapWindow = async (pathToComponent = '') => {
|
|
10
10
|
const url = new URL(`${window?.location?.origin}/api/_test/bootstrap`);
|
|
11
11
|
url.search = new URLSearchParams({ pathToComponent });
|
|
12
12
|
|
|
@@ -67,7 +67,7 @@ export default async (pathToComponent = '', options = {}) => {
|
|
|
67
67
|
origin: `http://localhost:${process.env.PORT}`,
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
await bootstrapWindow();
|
|
70
|
+
await bootstrapWindow(pathToComponent);
|
|
71
71
|
|
|
72
72
|
// NOTE: Force default to true as that's the prescribed pattern for
|
|
73
73
|
// Joystick component files.
|