Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,29 @@ describe("decision.show command", () => {
});

it("defaults non-TTY output to JSON when no format is supplied", async () => {
Renderer.reset();
handle.mockResolvedValue({ decision });

await decisionShow({ id: "dec_123" }, container as IApplicationContainer);

expect(stdout).toHaveBeenCalledTimes(1);
expect(JSON.parse(String(stdout.mock.calls[0][0]))).toEqual(decision);
const isTtyDescriptor = Object.getOwnPropertyDescriptor(process.stdout, "isTTY");
Object.defineProperty(process.stdout, "isTTY", {
configurable: true,
value: false,
});

try {
Renderer.reset();
handle.mockResolvedValue({ decision });

await decisionShow({ id: "dec_123" }, container as IApplicationContainer);

expect(stdout).toHaveBeenCalledTimes(1);
expect(JSON.parse(String(stdout.mock.calls[0][0]))).toEqual(decision);
} finally {
Renderer.reset();

if (isTtyDescriptor) {
Object.defineProperty(process.stdout, "isTTY", isTtyDescriptor);
} else {
Reflect.deleteProperty(process.stdout, "isTTY");
}
}
});

it("reports unknown IDs only on stderr and sets a non-zero exit code", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ describe("project.init command", () => {

if (isTtyDescriptor) {
Object.defineProperty(process.stdout, "isTTY", isTtyDescriptor);
} else {
Reflect.deleteProperty(process.stdout, "isTTY");
}
});

Expand Down
Loading