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
2 changes: 1 addition & 1 deletion src/commands/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export async function buildsCommand(
if (options.build) {
output.startSpinner('Fetching build...');
let include = options.comparisons ? 'comparisons' : undefined;
let response = await getBuild(client, options.build, { include });
let response = await getBuild(client, options.build, include);
output.stopSpinner();

let build = response.build || response;
Expand Down
4 changes: 1 addition & 3 deletions src/commands/comparisons.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ export async function comparisonsCommand(
// Get comparisons for a specific build
if (options.build) {
output.startSpinner('Fetching comparisons for build...');
let response = await getBuild(client, options.build, {
include: 'comparisons',
});
let response = await getBuild(client, options.build, 'comparisons');
output.stopSpinner();

let build = response.build || response;
Expand Down
44 changes: 44 additions & 0 deletions tests/commands/builds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,50 @@ describe('commands/builds', () => {
assert.strictEqual(dataCall.args[0].id, 'build-1');
});

it('passes include as a string to getBuild when --comparisons is set', async () => {
let output = createMockOutput();
let capturedInclude = null;

await buildsCommand(
{ build: 'build-1', comparisons: true },
{ json: true },
{
loadConfig: async () => ({ apiKey: 'test-token' }),
createApiClient: () => ({}),
getBuild: async (_client, _buildId, include) => {
capturedInclude = include;
return { build: { id: 'build-1', status: 'completed' } };
},
output,
exit: () => {},
}
);

assert.strictEqual(capturedInclude, 'comparisons');
});

it('passes undefined include to getBuild when --comparisons is not set', async () => {
let output = createMockOutput();
let capturedInclude = 'NOT_CALLED';

await buildsCommand(
{ build: 'build-1' },
{ json: true },
{
loadConfig: async () => ({ apiKey: 'test-token' }),
createApiClient: () => ({}),
getBuild: async (_client, _buildId, include) => {
capturedInclude = include;
return { build: { id: 'build-1', status: 'completed' } };
},
output,
exit: () => {},
}
);

assert.strictEqual(capturedInclude, undefined);
});

it('passes filters to API', async () => {
let output = createMockOutput();
let capturedFilters = null;
Expand Down
22 changes: 22 additions & 0 deletions tests/commands/comparisons.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,28 @@ describe('commands/comparisons', () => {
assert.strictEqual(dataCall.args[0].summary.failed, 1);
});

it('passes include as a string to getBuild, not an object', async () => {
let output = createMockOutput();
let capturedInclude = null;

await comparisonsCommand(
{ build: 'build-1' },
{ json: true },
{
loadConfig: async () => ({ apiKey: 'test-token' }),
createApiClient: () => ({}),
getBuild: async (_client, _buildId, include) => {
capturedInclude = include;
return { build: { id: 'build-1', comparisons: [] } };
},
output,
exit: () => {},
}
);

assert.strictEqual(capturedInclude, 'comparisons');
});

it('searches comparisons by name', async () => {
let output = createMockOutput();
let capturedName = null;
Expand Down