Skip to content

Commit 2409769

Browse files
committed
Fix makeContext to preserve stream defaults when overriding properties
The makeContext helper was incorrectly spreading all overrides at the end, which clobbered the carefully-constructed stdin/stdout/stderr objects with their merged defaults. This caused tests to exercise code paths with malformed context objects missing columns/rows, resulting in COLUMNS=undefined and LINES=undefined being passed to docker exec. Fixed by destructuring stream keys from overrides and only spreading the remaining properties, ensuring per-property merging takes effect.
1 parent 4d01540 commit 2409769

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

test/tty-allocation.spec.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ chai.should();
2020
const {buildExecArgs} = require('../utils/build-docker-exec');
2121

2222
// Helper to build a minimal context object for testing
23-
const makeContext = (overrides = {}) => ({
24-
stdin: {isTTY: false, isClosed: false, ...overrides.stdin},
25-
stdout: {isTTY: false, columns: 80, rows: 24, ...overrides.stdout},
26-
stderr: {isTTY: false, ...overrides.stderr},
27-
isNodeMode: true,
28-
ci: false,
29-
noColor: false,
30-
forceColor: undefined,
31-
...overrides,
32-
});
23+
const makeContext = (overrides = {}) => {
24+
const {stdin, stdout, stderr, ...rest} = overrides;
25+
return {
26+
stdin: {isTTY: false, isClosed: false, ...stdin},
27+
stdout: {isTTY: false, columns: 80, rows: 24, ...stdout},
28+
stderr: {isTTY: false, ...stderr},
29+
isNodeMode: true,
30+
ci: false,
31+
noColor: false,
32+
forceColor: undefined,
33+
...rest,
34+
};
35+
};
3336

3437
// Helper to build a minimal datum object for testing
3538
const makeDatum = (overrides = {}) => ({

0 commit comments

Comments
 (0)