Skip to content

Commit

Permalink
fix: corrects exception on diff command and removes redundant share o…
Browse files Browse the repository at this point in the history
…perator (#63)

* fix(cli): Corrects exception on diff command, closes #61

* chore(cli): Removes redundant share operator

* chore: add basic e2e test for diff
  • Loading branch information
gdorsi authored and boneskull committed Nov 13, 2019
1 parent 5dc2ca4 commit fe0d799
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
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
}
);
});
});
});

0 comments on commit fe0d799

Please sign in to comment.