@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 m,URLSearchParams as w}from"url";import p from"./event.js";import h from"../load/index.js";const u=async()=>{const e=new m(`${window?.location?.origin}/api/_test/bootstrap`);e.search=new w({pathToComponent});const t=await l(e).then(async n=>n.json());window.joystick={},window.joystick.settings={},window.__joystick_data__=t?.data||{},window.__joystick_i18n__=t?.translations||{},window.__joystick_req__=t?.req,console.log(t)},g=()=>{const e=i(`
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:t,document:n,Element:s,Event:r,HTMLElement:o}=e;return global.window=t,global.document=n,global.HTMLElement=o,global.Element=s,global.Event=r,global.console={log:console.log,warn:console.warn,error:console.error},e};var k=async(e="",t={})=>{const n=g();window.fetch=l,window.location={origin:`http://localhost:${process.env.PORT}`},await u();const s=await h(e,{default:!0}),r=d.mount(s,t?.props||{},n?.document.querySelector("#app"));return r.isTest=!0,{dom:n,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,"")?.replace(/\n|\t/g," ")?.replace(/> *</g,"><")},method:(o="",...a)=>{const c=r?.methods[o];return c?c(...a):null},event:(o="",a="")=>p(o,a,n)}}};export{k as default};
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/test-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.71",
4
+ "version": "0.0.0-canary.72",
5
5
  "description": "Isomorphic testing framework for the Joystick JavaScript framework.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
@@ -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.