Skip to content

Commit 804e147

Browse files
author
akhushnood
committed
Add Unit Test for parsing severity and fix import in ESLintParser.ts
1 parent 6e88f08 commit 804e147

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Parser/ESLintParser.spec.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,20 @@ describe('ESLintParser', () => {
113113
const result = new ESLintParser(cwd).parse(mockedContentString);
114114
const valid = result.filter((el) => el.valid);
115115
const invalid = result.filter((el) => !el.valid);
116-
expect(valid).toHaveLength(1);
116+
expect(valid).toHaveLength(2);
117117
expect(invalid).toHaveLength(1);
118118
});
119119

120+
it('Should parse with severity correctly', () => {
121+
const result = new ESLintParser(cwd).parse(mockedContentString);
122+
const resultWithError = result.filter((el) => el.severity === LintSeverity.error);
123+
const resultWithWarning = result.filter((el) => el.severity === LintSeverity.warning);
124+
const ignoredResult = result.filter((el) => el.severity === LintSeverity.ignore);
125+
expect(resultWithError).toHaveLength(1);
126+
expect(resultWithWarning).toHaveLength(1);
127+
expect(ignoredResult).toHaveLength(1);
128+
});
129+
120130
it('Should throw error if the line not match the rule', () => {
121131
expect(() => new ESLintParser(cwd).parse(':')).toThrow();
122132
});

src/Parser/ESLintParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProjectType } from '../Config';
1+
import { ProjectType } from '../Config/@enums';
22
import { Log } from '../Logger';
33
import { getRelativePath } from './utils/path.util';
44
import { LintSeverity } from './@enums/LintSeverity';

0 commit comments

Comments
 (0)