Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@ jobs:
- name: The job has failed
if: ${{ failure() }}
run: cat server/prosody.err

test-deno:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Run Deno tests
run: deno test --allow-read test/deno.test.js
49 changes: 49 additions & 0 deletions test/deno.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Smoke tests to verify xmpp.js core packages work with Deno runtime
import { jid } from "../packages/jid/index.js";
import id from "../packages/id/index.js";

function assertEquals(actual, expected, message) {
if (actual !== expected) {
throw new Error(message || `Expected ${expected}, got ${actual}`);
}
}

function assertNotEquals(actual, expected, message) {
if (actual === expected) {
throw new Error(message || `Expected values to be different, but both were ${actual}`);
}
}

Deno.test("JID - basic address handling", () => {
const addr = jid("foo@bar/baz");
assertEquals(addr.toString(), "foo@bar/baz");
assertEquals(addr.local, "foo");
assertEquals(addr.domain, "bar");
assertEquals(addr.resource, "baz");
});

Deno.test("JID - parsing", () => {
const parsed = jid("[email protected]");
assertEquals(parsed.local, "user");
assertEquals(parsed.domain, "example.com");
});

Deno.test("JID - equality", () => {
const addr1 = jid("[email protected]/resource");
const addr2 = jid("[email protected]/resource");
assertEquals(addr1.equals(addr2), true);
});

Deno.test("JID - bare address", () => {
const withResource = jid("[email protected]/mobile");
const bare = withResource.bare();
assertEquals(bare.toString(), "[email protected]");
});

Deno.test("ID - unique generation", () => {
const id1 = id();
const id2 = id();
assertEquals(typeof id1, "string");
assertEquals(id1.length > 0, true);
assertNotEquals(id1, id2);
});