Skip to content

Commit

Permalink
test: absolute socket and full pipe paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastercuber committed Sep 17, 2023
1 parent 63c0f57 commit 397217d
Showing 1 changed file with 46 additions and 19 deletions.
65 changes: 46 additions & 19 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,26 +308,53 @@ describe("listhen", () => {
});

describe("_utils", () => {
test("getSocketPath: empty ipcSocketName resolves to a 'listhen' named pipe/socket", () => {
if (platform() === "win32") {
expect(getSocketPath(undefined!)).toEqual("\\\\?\\pipe\\listhen");
expect(getSocketPath("")).toEqual("\\\\?\\pipe\\listhen");
} else {
expect(getSocketPath(undefined!)).toEqual("/tmp/listhen.socket");
expect(getSocketPath("")).toEqual("/tmp/listhen.socket");
}
});
describe("socket path", () => {
test("empty ipcSocketName resolves to a 'listhen' named pipe/socket", () => {
if (platform() === "win32") {
expect(getSocketPath(undefined!)).toEqual("\\\\?\\pipe\\listhen");
expect(getSocketPath("")).toEqual("\\\\?\\pipe\\listhen");
} else {
expect(getSocketPath(undefined!)).toEqual("/tmp/listhen.socket");
expect(getSocketPath("")).toEqual("/tmp/listhen.socket");
}
});

test("some string as ipcSocketName resolves to a pipe/socket named as this string", () => {
if (platform() === "win32") {
expect(getSocketPath("listhen-https")).toEqual(
"\\\\?\\pipe\\listhen-https",
);
} else {
expect(getSocketPath("listhen-https")).toEqual(
"/tmp/listhen-https.socket",
);
}
});

test("getSocketPath: some string as ipcSocketName resolves to a pipe/socket named as this string", () => {
if (platform() === "win32") {
expect(getSocketPath("listhen-https")).toEqual(
"\\\\?\\pipe\\listhen-https",
);
} else {
expect(getSocketPath("listhen-https")).toEqual(
"/tmp/listhen-https.socket",
);
}
test("absolute path (or full pipe path) resolves to the exact same path", () => {
if (platform() === "win32") {
const pipe = "\\\\?\\pipe\\listhen";
expect(getSocketPath(pipe)).toEqual(pipe);
} else {
const socket = "/tmp/listhen.socket";
expect(getSocketPath(socket)).toEqual(socket);
}
});

test("relative path resolves to a socket named as this relative path", () => {
if (platform() === "win32") {
expect(getSocketPath("tmp\\listhen")).toEqual(
"\\\\?\\pipe\\tmp\\listhen",
);
} else {
expect(getSocketPath("tmp/listhen.socket")).toEqual(
"/tmp/tmp/listhen.socket.socket",
);
expect(getSocketPath("tmp/listhen")).toEqual(
"/tmp/tmp/listhen.socket",
);
}
});
});
});
});

0 comments on commit 397217d

Please sign in to comment.