mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(tests): iteration 1
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { existsSync, readFileSync } from "node:fs";
|
||||
import { execFileSync } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const THIS_DIR = path.dirname(fileURLToPath(import.meta.url));
|
||||
const DIST_ENCRYPTED_CHANNEL_PATH = path.resolve(THIS_DIR, "../dist/encrypted-channel.js");
|
||||
const RELAY_PACKAGE_ROOT = path.resolve(THIS_DIR, "..");
|
||||
|
||||
function readBuiltEncryptedChannel(): string {
|
||||
if (!existsSync(DIST_ENCRYPTED_CHANNEL_PATH)) {
|
||||
execFileSync("npm", ["run", "build"], {
|
||||
cwd: RELAY_PACKAGE_ROOT,
|
||||
stdio: "inherit",
|
||||
});
|
||||
}
|
||||
|
||||
return readFileSync(DIST_ENCRYPTED_CHANNEL_PATH, "utf8");
|
||||
}
|
||||
|
||||
describe("relay dist handshake parity", () => {
|
||||
it("keeps Node dist handshake message types in sync with src", () => {
|
||||
const distCode = readFileSync(DIST_ENCRYPTED_CHANNEL_PATH, "utf8");
|
||||
const distCode = readBuiltEncryptedChannel();
|
||||
|
||||
expect(distCode).toContain('type: "e2ee_hello"');
|
||||
expect(distCode).toContain('type: "e2ee_ready"');
|
||||
@@ -18,4 +31,3 @@ describe("relay dist handshake parity", () => {
|
||||
expect(distCode).not.toMatch(/\btype:\s*"ready"\b/);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user