From f12d4a61ca12d1e037c0375201b98893bb56cbe7 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 21 Dec 2024 12:22:46 +0100 Subject: [PATCH] f --- Makefile | 7 +++++-- package.json | 2 -- packages/component/index.js | 2 +- packages/resolve/lib/http.js | 13 +++++-------- server/index.js | 4 +++- test/component.js | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 4d99866c..a6a5f83f 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ test: ci: npm install - npx jest + make unit make lint make restart npx lerna run prepublish @@ -27,8 +27,11 @@ ci: make e2e make bundlesize +unit: + npx jest + e2e: - NODE_TLS_REJECT_UNAUTHORIZED=0 npx jest --runInBand --config e2e.config.js + NODE_TLS_REJECT_UNAUTHORIZED=0 npx jest --runInBand --config e2e.config.cjs clean: make stop diff --git a/package.json b/package.json index 81890e54..b60f443a 100644 --- a/package.json +++ b/package.json @@ -39,8 +39,6 @@ "uglify-js": "^3.19.3" }, "scripts": { - "test": "npx jest", - "lint": "eslint --cache .", "preversion": "make bundle" }, "engines": { diff --git a/packages/component/index.js b/packages/component/index.js index b69d62cd..8e3935b0 100644 --- a/packages/component/index.js +++ b/packages/component/index.js @@ -35,4 +35,4 @@ function component(options) { }); } -export default { xml, jid, component }; +export { xml, jid, component }; diff --git a/packages/resolve/lib/http.js b/packages/resolve/lib/http.js index 03b8b3a3..cbba7366 100644 --- a/packages/resolve/lib/http.js +++ b/packages/resolve/lib/http.js @@ -1,14 +1,11 @@ - -// FIXME -// const fetch = globalThis.fetch || import("node-fetch"); - import parse from "@xmpp/xml/lib/parse.js"; import { compare as compareAltConnections } from "./alt-connections.js"; -export function resolve(domain) { - // eslint-disable-next-line n/no-unsupported-features/node-builtins - return globalThis - .fetch(`https://${domain}/.well-known/host-meta`) +export async function resolve(domain) { + // eslint-disable-next-line n/no-unsupported-features/node-builtins, unicorn/no-await-expression-member + const fetch = globalThis.fetch || (await import("node-fetch")).default; + + return fetch(`https://${domain}/.well-known/host-meta`) .then((res) => res.text()) .then((res) => { return parse(res) diff --git a/server/index.js b/server/index.js index 3c96736d..37870930 100644 --- a/server/index.js +++ b/server/index.js @@ -7,6 +7,8 @@ import net from "net"; import { promise, delay } from "@xmpp/events"; import selfsigned from "selfsigned"; +// const __dirname = import.meta.dirname; + const readFile = promisify(fs.readFile); const exec = promisify(child_process.exec); const removeFile = promisify(fs.unlink); @@ -116,7 +118,7 @@ async function restart(signal) { return _start(); } -export { +export default { isPortOpen, waitPortClose, waitPortOpen, diff --git a/test/component.js b/test/component.js index 503714e7..aa922dc6 100644 --- a/test/component.js +++ b/test/component.js @@ -9,10 +9,10 @@ const options = { password, service, domain }; let xmpp; -beforeEach(() => { +beforeEach(async () => { xmpp = component(options); debug(xmpp); - return server.restart(); + await server.restart(); }); afterEach(async () => {