@joystick.js/test-canary 0.0.0-canary.53 → 0.0.0-canary.55

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.
package/_package.json CHANGED
@@ -22,6 +22,7 @@
22
22
  "linkedom": "^0.15.1",
23
23
  "mongo-uri-tool": "^1.0.1",
24
24
  "mongodb": "^5.7.0",
25
+ "node-fetch": "^3.3.2",
25
26
  "pg": "^8.11.2"
26
27
  }
27
28
  }
@@ -1,4 +1,4 @@
1
- import{parseHTML as m}from"linkedom";import d from"@joystick.js/ui-canary";import s from"./event.js";import i from"../load/index.js";const p=()=>{const n=m(`
1
+ import{parseHTML as m}from"linkedom";import d from"@joystick.js/ui-canary";import s from"node-fetch";import i from"./event.js";import p from"../load/index.js";const u=()=>{const n=m(`
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:t,Element:a,Event:e,HTMLElement:o}=n;return global.window=r,global.document=t,global.HTMLElement=o,global.Element=a,global.Event=e,global.console={log:console.log,warn:console.warn,error:console.error},n};var f=async(n="",r={})=>{const t=p();window.joystick={},window.__joystick_data__={},window.__joystick_req__={params:{},query:{},context:{user:{}}};const a=await i(n,{default:!0}),e=d.mount(a,r?.props||{},t?.document.querySelector("#app"));return{...t,component:e,test:{data:async()=>{try{await e?.data?.refetch()}catch(o){console.warn(o)}},method:(o="",...l)=>{const c=e?.methods[o];return c?c(...l):null},event:(o="",l="")=>s(o,l,t)}}};export{f as default};
9
+ `),{window:r,document:o,Element:l,Event:t,HTMLElement:e}=n;return global.window=r,global.document=o,global.HTMLElement=e,global.Element=l,global.Event=t,global.console={log:console.log,warn:console.warn,error:console.error},n};var g=async(n="",r={})=>{const o=u();window.fetch=s,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=d.mount(l,r?.props||{},o?.document.querySelector("#app"));return{...o,component:t,test:{data:async()=>t?.data?.refetch(),method:(e="",...a)=>{const c=t?.methods[e];return c?c(...a):null},event:(e="",a="")=>i(e,a,o)}}};export{g 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.53",
4
+ "version": "0.0.0-canary.55",
5
5
  "description": "Isomorphic testing framework for the Joystick JavaScript framework.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
@@ -1,6 +1,7 @@
1
1
 
2
2
  import { parseHTML } from 'linkedom';
3
3
  import joystick from '@joystick.js/ui-canary';
4
+ import fetch from 'node-fetch';
4
5
  import event from './event.js';
5
6
  import load from "../load/index.js";
6
7
 
@@ -33,6 +34,10 @@ const loadDOM = () => {
33
34
  export default async (pathToComponent = '', options = {}) => {
34
35
  const dom = loadDOM();
35
36
 
37
+ window.fetch = fetch;
38
+ window.location = {
39
+ origin: `http://localhost:${process.env.PORT}`,
40
+ };
36
41
  window.joystick = {};
37
42
  window.__joystick_data__ = {};
38
43
  window.__joystick_req__ = { params: {}, query: {}, context: { user: {} } };
@@ -47,11 +52,7 @@ export default async (pathToComponent = '', options = {}) => {
47
52
  component,
48
53
  test: {
49
54
  data: async () => {
50
- try {
51
- await component?.data?.refetch();
52
- } catch (exception) {
53
- console.warn(exception);
54
- }
55
+ return component?.data?.refetch();
55
56
  },
56
57
  method: (methodName = '', ...methodArgs) => {
57
58
  const methodToCall = component?.methods[methodName];