@joystick.js/test-canary 0.0.0-canary.55 → 0.0.0-canary.57
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
|
|
1
|
+
import{parseHTML as s}from"linkedom";import m from"@joystick.js/ui-canary";import d from"node-fetch";import i from"./event.js";import p from"../load/index.js";const u=()=>{const n=s(`
|
|
2
2
|
<html>
|
|
3
3
|
<head></head>
|
|
4
4
|
<body>
|
|
@@ -6,4 +6,4 @@ import{parseHTML as m}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:r,document:
|
|
9
|
+
`),{window:r,document:e,Element:l,Event:t,HTMLElement:o}=n;return global.window=r,global.document=e,global.HTMLElement=o,global.Element=l,global.Event=t,global.console={log:console.log,warn:console.warn,error:console.error},n};var g=async(n="",r={})=>{const e=u();window.fetch=d,window.location={origin:`http://localhost:${process.env.PORT}`},window.joystick={},window.__joystick_data__={},window.__joystick_req__={params:{},query:{},context:{user:{}}};const l=await p(n,{default:!0}),t=m.mount(l,r?.props||{},e?.document.querySelector("#app"));return t.isTest=!0,{...e,component:t,test:{data:async(o={})=>t?.data?.refetch(o),method:(o="",...a)=>{const c=t?.methods[o];return c?c(...a):null},event:(o="",a="")=>i(o,a,e)}}};export{g as default};
|
package/package.json
CHANGED
package/src/helpers/dom/index.js
CHANGED
|
@@ -47,12 +47,15 @@ export default async (pathToComponent = '', options = {}) => {
|
|
|
47
47
|
const Component = await load(pathToComponent, { default: true });
|
|
48
48
|
const component = joystick.mount(Component, options?.props || {}, dom?.document.querySelector('#app'));
|
|
49
49
|
|
|
50
|
+
// NOTE: Used internally in @joystick.js/ui to control component behavior.
|
|
51
|
+
component.isTest = true;
|
|
52
|
+
|
|
50
53
|
return {
|
|
51
54
|
...dom,
|
|
52
55
|
component,
|
|
53
56
|
test: {
|
|
54
|
-
data: async () => {
|
|
55
|
-
return component?.data?.refetch();
|
|
57
|
+
data: async (input = {}) => {
|
|
58
|
+
return component?.data?.refetch(input);
|
|
56
59
|
},
|
|
57
60
|
method: (methodName = '', ...methodArgs) => {
|
|
58
61
|
const methodToCall = component?.methods[methodName];
|