From 77047bab4318200380b4e33e83b259a78f8ff6a6 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Mon, 17 Nov 2025 17:04:29 +0000
Subject: [PATCH] GS-2373

---
 test/testConnect.js |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/test/testConnect.js b/test/testConnect.js
new file mode 100644
index 0000000..0f54a1d
--- /dev/null
+++ b/test/testConnect.js
@@ -0,0 +1,81 @@
+/**
+ * Testing connection to all components
+ */
+
+const expect = require("chai").expect
+
+const settings = require("../settings")
+const libIlias = require("../lib/libIlias")
+const db = require("../lib/db");
+
+/////////////////////////////////////////////////////////////////////////
+
+describe("connection test", function () {
+
+
+   beforeEach(async function () {
+   })
+
+   afterEach(async function () {
+   })
+
+   describe("the ILIAS URL", function () {
+      it("should be accessible", async function () {
+         const urlS = settings.ilias.url
+         const urlD = new URL(urlS)
+         const url = urlD.origin
+
+         const res = await fetch(url)
+         expect(res.status).to.equal(200)
+         expect(res.statusText.toUpperCase()).to.equal("OK")
+         const text = await res.text()
+         expect(text).to.contain("html")
+         expect(text).to.contain("ILIAS")
+      })
+      it("should use https", async function () {
+         const urlS = settings.ilias.url
+         const urlD = new URL(urlS)
+         expect(urlD.protocol).to.equal("https:")
+      })
+   })
+
+   describe("the Database", function () {
+      it("should be accessible", async function () {
+         const db = require("../lib/db")
+         const res = await db.getUsers(0, 1)
+         // console.log(res)
+
+         expect(res).to.be.a("object")
+         expect(res.total).to.be.a("number").above(0)
+         expect(res.offset).to.equal(0)
+         expect(res.limit).to.equal(1)
+
+         const data = res.data
+         expect(data).to.be.a("array").and.to.be.lengthOf(1)
+
+         const user = data[0]
+         expect(user.usr_id).to.be.a("number").above(0)
+         expect(user).to.have.property("login")
+         expect(user).to.have.property("firstname")
+         expect(user).to.have.property("lastname")
+      })
+   })
+
+   describe("the PHP component", function () {
+      it("should respond to a ping request", async function () {
+         const libIlias = require("../lib/libIlias")
+         const res = await libIlias.ping()
+         // console.log(res)
+
+         expect(res).to.be.a("object")
+         expect(res.method).to.equal("GET")
+         expect(res.command).to.equal("ping")
+         expect(res.status).to.equal("ok")
+      })
+   })
+
+
+})
+
+/////////////////////////////////////////////////////////////////////////
+

--
Gitblit v1.8.0