Skip to content

Commit 0d78e94

Browse files
authored
Merge pull request #76 from simonihmig/add-reporting-test
Add bin test for error reporting
2 parents f390468 + 562d13e commit 0d78e94

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

__tests__/bin-test.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const tmp = require('tmp');
77

88
const originalCwd = process.cwd();
99

10-
const inputFile = path.join(originalCwd, '__testfixtures__/final-boss.input.js');
11-
const outputFile = path.join(originalCwd, '__testfixtures__/final-boss.output.js');
12-
1310
let tmpPath;
1411

1512
function run() {
@@ -95,6 +92,9 @@ describe('bin acceptance', function() {
9592

9693
describe('with valid file', function() {
9794
let tmpFile;
95+
const inputFile = path.join(originalCwd, '__testfixtures__/final-boss.input.js');
96+
const outputFile = path.join(originalCwd, '__testfixtures__/final-boss.output.js');
97+
9898

9999
beforeEach(function() {
100100
fs.ensureDirSync(path.join(tmpPath, 'app'));
@@ -120,5 +120,37 @@ describe('bin acceptance', function() {
120120
});
121121
});
122122
});
123+
124+
describe('with invalid file', function() {
125+
const inputFile = path.join(originalCwd, '__testfixtures__/leave-unmatched-destructuring.input.js');
126+
127+
beforeEach(function() {
128+
fs.ensureDirSync(path.join(tmpPath, 'app'));
129+
130+
let tmpFile = path.join(tmpPath, 'app/leave-unmatched-destructuring.input.js');
131+
132+
fs.copySync(
133+
inputFile,
134+
tmpFile
135+
);
136+
});
137+
138+
it('reports errors', function() {
139+
return run().then(result => {
140+
let exitCode = result.exitCode;
141+
let stdout = result.stdout;
142+
143+
expect(exitCode).toEqual(0);
144+
145+
expect(stdout).toMatch('Done! Some files could not be upgraded automatically. See MODULE_REPORT.md.\n');
146+
147+
let expectedOutput = fs.readFileSync(path.join(__dirname, 'expected', 'MODULE_REPORT.md'), 'utf8')
148+
.replace(/\//, path.sep);
149+
let actualOutput = fs.readFileSync(path.join(tmpPath, 'MODULE_REPORT.md'), 'utf8');
150+
151+
expect(actualOutput).toEqual(expectedOutput);
152+
});
153+
});
154+
});
123155
});
124156
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Module Report
2+
### Unknown Global
3+
4+
**Global**: `Ember.String.pluralize`
5+
6+
**Location**: `app/leave-unmatched-destructuring.input.js` at line 5
7+
8+
```js
9+
const {
10+
String: {
11+
pluralize,
12+
camelize
13+
}
14+
```

0 commit comments

Comments
 (0)