simplify tests
This commit is contained in:
parent
d4bfe556bf
commit
0ff7ae09f9
1 changed files with 25 additions and 78 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { getDefaultEnvironment, StdioClientTransport } from "./stdio.js";
|
||||
import { StdioClientTransport, getDefaultEnvironment } from "./stdio.js";
|
||||
import spawn from "cross-spawn";
|
||||
import { JSONRPCMessage } from "../types.js";
|
||||
import { ChildProcess } from "node:child_process";
|
||||
|
|
@ -67,19 +67,37 @@ describe("StdioClientTransport using cross-spawn", () => {
|
|||
|
||||
await transport.start();
|
||||
|
||||
// verify environment variables are passed correctly
|
||||
// verify environment variables are merged correctly
|
||||
expect(mockSpawn).toHaveBeenCalledWith(
|
||||
"test-command",
|
||||
[],
|
||||
expect.objectContaining({
|
||||
env: {
|
||||
...getDefaultEnvironment(),
|
||||
...customEnv,
|
||||
...customEnv
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("should use default environment when env is undefined", async () => {
|
||||
const transport = new StdioClientTransport({
|
||||
command: "test-command",
|
||||
env: undefined
|
||||
});
|
||||
|
||||
await transport.start();
|
||||
|
||||
// verify default environment is used
|
||||
expect(mockSpawn).toHaveBeenCalledWith(
|
||||
"test-command",
|
||||
[],
|
||||
expect.objectContaining({
|
||||
env: getDefaultEnvironment()
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
test("should send messages correctly", async () => {
|
||||
const transport = new StdioClientTransport({
|
||||
command: "test-command"
|
||||
|
|
|
|||
Loading…
Reference in a new issue