Jest to Vitest migration (#230)

* working without clean up

* clean up dependencies

* use test not dev

* add tests for kclErrToDiagnostic

* remove jest config

* remove unneeded @ts-ignore
This commit is contained in:
Kurt Hutten
2023-08-08 10:50:27 +10:00
committed by GitHub
parent ca985dd1a8
commit 7a537eea8e
10 changed files with 796 additions and 1575 deletions

51
src/lang/errors.test.ts Normal file
View File

@ -0,0 +1,51 @@
import { kclErrToDiagnostic, KCLError } from './errors'
describe('test kclErrToDiagnostic', () => {
it('converts KCL errors to CodeMirror diagnostics', () => {
const errors: KCLError[] = [
{
kind: 'semantic',
msg: 'Semantic error',
sourceRanges: [
[0, 1],
[2, 3],
],
},
{
kind: 'type',
msg: 'Type error',
sourceRanges: [
[4, 5],
[6, 7],
],
},
]
const diagnostics = kclErrToDiagnostic(errors)
expect(diagnostics).toEqual([
{
from: 0,
to: 1,
message: 'Semantic error',
severity: 'error',
},
{
from: 2,
to: 3,
message: 'Semantic error',
severity: 'error',
},
{
from: 4,
to: 5,
message: 'Type error',
severity: 'error',
},
{
from: 6,
to: 7,
message: 'Type error',
severity: 'error',
},
])
})
})