mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 12:57:47 +00:00
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).
31 lines
1.0 KiB
TypeScript
31 lines
1.0 KiB
TypeScript
import { client } from '../mocks/client';
|
|
import { useUser } from '../mocks/user';
|
|
import { useDeployment } from '../mocks/deployment';
|
|
import inspect from '../../src/commands/inspect';
|
|
|
|
describe('inspect', () => {
|
|
it('should print out deployment information', async () => {
|
|
const user = useUser();
|
|
const deployment = useDeployment({ creator: user });
|
|
client.setArgv('inspect', deployment.url);
|
|
const exitCode = await inspect(client);
|
|
expect(exitCode).toEqual(0);
|
|
expect(
|
|
client.mockOutput.mock.calls[0][0].startsWith(
|
|
`> Fetched deployment "${deployment.url}" in ${user.username}`
|
|
)
|
|
).toBeTruthy();
|
|
});
|
|
|
|
it('should print error when deployment not found', async () => {
|
|
const user = useUser();
|
|
useDeployment({ creator: user });
|
|
client.setArgv('inspect', 'bad.com');
|
|
const exitCode = await inspect(client);
|
|
expect(exitCode).toEqual(1);
|
|
expect(client.outputBuffer).toEqual(
|
|
`Error! Failed to find deployment "bad.com" in ${user.username}\n`
|
|
);
|
|
});
|
|
});
|