[cli] Add outputBuffer getter and mutable isTTY for tests (#6827)

These changes originally from #6652, but pulled out to be merged
separately.

`outputBuffer` is a simpler way of asserting tests against the CLI
output instead of working directly withe Jest mock function.

`output.isTTY` is also now mutable, so that we can write tests for both
cases when the output is different based on TTY-ness (for example,
see the updated `vc whoami` tests in this PR).
This commit is contained in:
Nathan Rajlich
2021-10-12 16:16:55 -07:00
committed by GitHub
parent f682aefc9d
commit 1be75712e0
5 changed files with 21 additions and 13 deletions

View File

@@ -69,6 +69,12 @@ export class MockClient extends Client {
this.output.spinner = () => {};
this.scenario = Router();
this.output.isTTY = true;
}
get outputBuffer() {
return this.mockOutput.mock.calls.map(c => c[0]).join('');
}
async startMockServer() {