@joystick.js/test-canary 0.0.0-canary.60 → 0.0.0-canary.62
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 d}from"linkedom";import
|
|
1
|
+
import{parseHTML as d}from"linkedom";import w from"@joystick.js/ui-canary";import m from"node-fetch";import{URL as p,URLSearchParams as u}from"url";import h from"./event.js";import f from"../load/index.js";const y=()=>{const t=d(`
|
|
2
2
|
<html>
|
|
3
3
|
<head></head>
|
|
4
4
|
<body>
|
|
@@ -6,4 +6,4 @@ import{parseHTML as d}from"linkedom";import m from"@joystick.js/ui-canary";impor
|
|
|
6
6
|
<meta name="csrf" content="joystick_test" />
|
|
7
7
|
</body>
|
|
8
8
|
</html>
|
|
9
|
-
`),{window:
|
|
9
|
+
`),{window:a,document:e,Element:n,Event:s,HTMLElement:c}=t;return global.window=a,global.document=e,global.HTMLElement=c,global.Element=n,global.Event=s,global.console={log:console.log,warn:console.warn,error:console.error},t};var k=async(t="",a={})=>{const e=y();window.fetch=m,window.location={origin:`http://localhost:${process.env.PORT}`};const n=new p(`${window?.location?.origin}/api/_test/bootstrap`);n.search=new u({pathToComponent:t});const s=await m(n).then(async o=>o.json());window.joystick={},window.__joystick_data__=s?.data||{},window.__joystick_req__={params:{},query:{},context:{user:{}}};const c=await f(t,{default:!0}),r=w.mount(c,a?.props||{},e?.document.querySelector("#app"));return r.isTest=!0,{dom:e,instance:r,test:{data:async(o={})=>r?.data?.refetch(o),method:(o="",...l)=>{const i=r?.methods[o];return i?i(...l):null},event:(o="",l="")=>h(o,l,e)}}};export{k as default};
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { parseHTML } from 'linkedom';
|
|
3
3
|
import joystick from '@joystick.js/ui-canary';
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
|
+
import { URL, URLSearchParams } from 'url';
|
|
5
6
|
import event from './event.js';
|
|
6
7
|
import load from "../load/index.js";
|
|
7
8
|
|
|
@@ -39,9 +40,12 @@ export default async (pathToComponent = '', options = {}) => {
|
|
|
39
40
|
origin: `http://localhost:${process.env.PORT}`,
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
const
|
|
43
|
+
const url = new URL(`${window?.location?.origin}/api/_test/bootstrap`);
|
|
44
|
+
url.search = new URLSearchParams({
|
|
45
|
+
pathToComponent,
|
|
46
|
+
});
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
const bootstrap = await fetch(url).then(async (response) => response.json());
|
|
45
49
|
|
|
46
50
|
// TODO: This needs to be more heavily leveraged vis a vis the settings file.
|
|
47
51
|
// Basically, w/o a server we need to be able to pipe in certain data. I *can*
|
|
@@ -56,7 +60,7 @@ export default async (pathToComponent = '', options = {}) => {
|
|
|
56
60
|
// like config.test.users = [{ _id: 'abc123', emailAddress: '', password: '' }].
|
|
57
61
|
|
|
58
62
|
window.joystick = {};
|
|
59
|
-
window.__joystick_data__ = {};
|
|
63
|
+
window.__joystick_data__ = bootstrap?.data || {};
|
|
60
64
|
window.__joystick_req__ = { params: {}, query: {}, context: { user: {} } };
|
|
61
65
|
|
|
62
66
|
// NOTE: Force default to true as that's the prescribed pattern for
|