Skip to content

Commit b3dccb4

Browse files
committed
Add tests for displaying TSC errors
1 parent 176b34d commit b3dccb4

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.2.0 (2020-11-19)
4+
5+
Features:
6+
7+
1. Display a list of all errors that cannot be ignored.
8+
39
## v1.1.0 (2020-11-11)
410

511
Features:

src/cli/program.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,26 @@ describe('program', () => {
230230
);
231231
});
232232

233+
it('should display the errors that could be ignored', () => {
234+
looselyTypeCheckedFiles = ['a', 'b'];
235+
ignoredErrorCodes = ['TS1234'];
236+
const result = program(cliDependencies, [
237+
createErrorLine('a', 'TS1234'),
238+
createErrorLine('a', 'TS1597'),
239+
createErrorLine('c', 'TS1111'),
240+
createErrorLine('c', 'TS1234'),
241+
createErrorLine('d', 'TS1234'),
242+
]);
243+
244+
expect(result?.error).toBe(true);
245+
expect(cliDependencies.log).toHaveBeenCalledWith(
246+
createErrorLine('c', 'TS1234'),
247+
);
248+
expect(cliDependencies.log).toHaveBeenCalledWith(
249+
createErrorLine('d', 'TS1234'),
250+
);
251+
});
252+
233253
it('should report the number of files that no longer have to be ignored', () => {
234254
looselyTypeCheckedFiles = ['a', 'b'];
235255
ignoredErrorCodes = ['TS1234'];
@@ -266,6 +286,25 @@ describe('program', () => {
266286
);
267287
});
268288

289+
it('should display valid TSC errors', () => {
290+
looselyTypeCheckedFiles = ['a', 'b'];
291+
ignoredErrorCodes = ['TS1234'];
292+
const result = program(cliDependencies, [
293+
createErrorLine('a', 'TS1234'),
294+
createErrorLine('a', 'TS1597'),
295+
createErrorLine('c', 'TS1111'),
296+
createErrorLine('c', 'TS1234'),
297+
]);
298+
299+
expect(result?.error).toBe(true);
300+
expect(cliDependencies.log).toHaveBeenCalledWith(
301+
createErrorLine('a', 'TS1597'),
302+
);
303+
expect(cliDependencies.log).toHaveBeenCalledWith(
304+
createErrorLine('c', 'TS1111'),
305+
);
306+
});
307+
269308
it('should report the number of ignored errors that did not occur', () => {
270309
looselyTypeCheckedFiles = ['a'];
271310
ignoredErrorCodes = ['TS1111', 'TS2222', 'TS3333'];

0 commit comments

Comments
 (0)