-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix eslint normalization * test: add unit test Co-authored-by: Fredrik Blomqvist <fredrik.blomqvist.95@gmail.com>
- Loading branch information
1 parent
5b0ac3a
commit 95aa772
Showing
4 changed files
with
138 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 22 additions & 6 deletions
28
packages/vite-plugin-checker/__tests__/unit/logger.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
import { diagnosticToTerminalLog } from '../../src/logger' | ||
import { error1 as eslintError1, warning1 as eslintWarning1 } from './fixtures/eslintDiagnostic' | ||
import strip from 'strip-ansi' | ||
|
||
import { | ||
diagnosticToTerminalLog, | ||
NormalizedDiagnostic, | ||
normalizeEslintDiagnostic, | ||
} from '../../src/logger' | ||
import { | ||
error1 as eslintError1, | ||
warning1 as eslintWarning1, | ||
eslintResult1, | ||
} from './fixtures/eslintDiagnostic' | ||
|
||
describe('logger', () => { | ||
describe('diagnosticToTerminalLog', () => { | ||
it('get error', () => { | ||
const receive = strip(diagnosticToTerminalLog(eslintError1, 'ESLint')) | ||
expect(receive).toMatchSnapshot() | ||
const received = strip(diagnosticToTerminalLog(eslintError1, 'ESLint')) | ||
expect(received).toMatchSnapshot() | ||
}) | ||
|
||
it('get warning', () => { | ||
const receive = strip(diagnosticToTerminalLog(eslintWarning1, 'ESLint')) | ||
expect(receive).toMatchSnapshot() | ||
const received = strip(diagnosticToTerminalLog(eslintWarning1, 'ESLint')) | ||
expect(received).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('normalizeEslintDiagnostic', () => { | ||
it('get multiple errors', () => { | ||
const received = normalizeEslintDiagnostic(eslintResult1) | ||
expect(received).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters