-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 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
63 changes: 63 additions & 0 deletions
63
packages/langium/test/grammar/lsp/grammar-formatter.test.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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/****************************************************************************** | ||
* Copyright 2023 TypeFox GmbH | ||
* This program and the accompanying materials are made available under the | ||
* terms of the MIT License, which is available in the project root. | ||
******************************************************************************/ | ||
|
||
import { describe, test } from 'vitest'; | ||
import { EmptyFileSystem, createLangiumGrammarServices, expandToString } from 'langium'; | ||
import { expectFormatting } from 'langium/test'; | ||
|
||
const services = createLangiumGrammarServices(EmptyFileSystem); | ||
const formatting = expectFormatting(services.grammar); | ||
|
||
describe('Grammar Formatter', () => { | ||
|
||
test('Indents interface properties', async () => { | ||
await formatting({ | ||
before: expandToString` | ||
interface Test { | ||
// This is a comment | ||
a: string | ||
b: number | ||
// This is another comment | ||
c: boolean | ||
} | ||
`, | ||
after: expandToString` | ||
interface Test { | ||
// This is a comment | ||
a: string | ||
b: number | ||
// This is another comment | ||
c: boolean | ||
} | ||
` | ||
}); | ||
}); | ||
|
||
test('Formats interface extends references', async () => { | ||
await formatting({ | ||
before: expandToString` | ||
interface A extends B,C, D,E{} | ||
`, | ||
after: expandToString` | ||
interface A extends B, C, D, E { | ||
} | ||
` | ||
}); | ||
}); | ||
|
||
test('Formats union type definitions', async () => { | ||
await formatting({ | ||
before: expandToString` | ||
type A= B | C | D | ||
; | ||
`, | ||
after: expandToString` | ||
type A = B | C | D; | ||
` | ||
}); | ||
}); | ||
|
||
}); |
File renamed without changes.