|
1 |
| -import { afterEach, describe, expect, it } from 'vitest'; |
2 |
| -import { createSafeDsServices } from '../../../src/language/safe-ds-module.js'; |
3 |
| -import { AstNode, EmptyFileSystem } from 'langium'; |
| 1 | +import { AstNode, EmptyFileSystem, expandToString } from 'langium'; |
4 | 2 | import { clearDocuments } from 'langium/test';
|
5 |
| -import { getNodeOfType } from '../../helpers/nodeFinder.js'; |
| 3 | +import { afterEach, describe, expect, it } from 'vitest'; |
| 4 | +import { normalizeLineBreaks } from '../../../src/helpers/stringUtils.js'; |
6 | 5 | import {
|
7 | 6 | isSdsAnnotation,
|
8 | 7 | isSdsFunction,
|
9 | 8 | isSdsParameter,
|
10 | 9 | isSdsResult,
|
11 | 10 | isSdsTypeParameter,
|
12 | 11 | } from '../../../src/language/generated/ast.js';
|
| 12 | +import { createSafeDsServices } from '../../../src/language/index.js'; |
| 13 | +import { getNodeOfType } from '../../helpers/nodeFinder.js'; |
13 | 14 |
|
14 | 15 | const services = createSafeDsServices(EmptyFileSystem).SafeDs;
|
15 | 16 | const documentationProvider = services.documentation.DocumentationProvider;
|
@@ -166,11 +167,39 @@ describe('SafeDsDocumentationProvider', () => {
|
166 | 167 | predicate: isSdsTypeParameter,
|
167 | 168 | expectedDocumentation: undefined,
|
168 | 169 | },
|
| 170 | + { |
| 171 | + testName: 'custom tag rendering', |
| 172 | + code: ` |
| 173 | + /** |
| 174 | + * ${testDocumentation} |
| 175 | + * |
| 176 | + * @param param ${testDocumentation} |
| 177 | + * @result result ${testDocumentation} |
| 178 | + * @typeParam T ${testDocumentation} |
| 179 | + * @since 1.0.0 |
| 180 | + */ |
| 181 | + fun myFunction<T>(param: String) -> result: String |
| 182 | + `, |
| 183 | + predicate: isSdsFunction, |
| 184 | + expectedDocumentation: expandToString` |
| 185 | + Lorem ipsum. |
| 186 | +
|
| 187 | + **@param** *param* — Lorem ipsum. |
| 188 | +
|
| 189 | + **@result** *result* — Lorem ipsum. |
| 190 | +
|
| 191 | + **@typeParam** *T* — Lorem ipsum. |
| 192 | +
|
| 193 | + **@since** — 1.0.0 |
| 194 | + `, |
| 195 | + }, |
169 | 196 | ];
|
170 | 197 |
|
171 | 198 | it.each(testCases)('$testName', async ({ code, predicate, expectedDocumentation }) => {
|
172 | 199 | const node = await getNodeOfType(services, code, predicate);
|
173 |
| - expect(documentationProvider.getDocumentation(node)).toStrictEqual(expectedDocumentation); |
| 200 | + const normalizedActual = normalizeLineBreaks(documentationProvider.getDocumentation(node)); |
| 201 | + const normalizedExpected = normalizeLineBreaks(expectedDocumentation); |
| 202 | + expect(normalizedActual).toStrictEqual(normalizedExpected); |
174 | 203 | });
|
175 | 204 |
|
176 | 205 | it('should resolve links', async () => {
|
|
0 commit comments