Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrects exception on diff command and removes redundant share operator #63

Merged
merged 3 commits into from
Nov 13, 2019
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
11 changes: 4 additions & 7 deletions packages/cli/src/commands/diff.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {_, observable} from '@report-toolkit/common';
import {_} from '@report-toolkit/common';
import {observable as observableAPI} from '@report-toolkit/core';

import {terminalColumns, toOutput} from '../console-utils.js';
Expand All @@ -11,7 +11,6 @@ import {
} from './common.js';

const {diff, transform, fromTransformerChain} = observableAPI;
const {share} = observable;

const OP_COLORS = _.toFrozenMap({
add: 'green',
Expand Down Expand Up @@ -120,11 +119,9 @@ export const handler = argv => {
});

const source = diff(
fromFilepathsToReports(file1).pipe(share()),
fromFilepathsToReports(file2).pipe(
share(),
config
)
fromFilepathsToReports(file1),
fromFilepathsToReports(file2),
config
);

fromTransformerChain(argv.transform, config)
Expand Down
34 changes: 34 additions & 0 deletions packages/cli/test/e2e/diff.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {runWithOptions} from './cli-helper.js';

const REPORT_001_FILEPATH = require.resolve(
'@report-toolkit/common/test/fixture/reports/report-001.json'
);
const REPORT_002_FILEPATH = require.resolve(
'@report-toolkit/common/test/fixture/reports/report-002-library-mismatch.json'
);

describe('@report-toolkit/cli:command:diff', function() {
describe('when run with a single report file', function() {
it('should exit with code 1', function() {
return expect(
runWithOptions(['diff', REPORT_001_FILEPATH]),
'to be rejected with error satisfying',
{
exitCode: 1
}
);
});
});

describe('when run with two report files', function() {
it('should exit with code 0', function() {
return expect(
runWithOptions(['diff', REPORT_001_FILEPATH, REPORT_002_FILEPATH]),
'to be fulfilled with value satisfying',
{
exitCode: 0
}
);
});
});
});