Skip to content

Commit 8e62f79

Browse files
committed
Add PR description example as a test case
Removed `MarkedString.fromPlainText` as that escapes the input and is not what we want here (we use `toMarkdown` which isn't the same)
1 parent 2a7ecb9 commit 8e62f79

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/test/hover.test.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as assert from 'assert';
77

8-
import { Hover, Position, MarkedString, TextDocument, getLanguageService, JSONSchema, LanguageServiceParams } from '../jsonLanguageService';
8+
import { Hover, Position, TextDocument, getLanguageService, JSONSchema, LanguageServiceParams } from '../jsonLanguageService';
99

1010
suite('JSON Hover', () => {
1111

@@ -33,7 +33,7 @@ suite('JSON Hover', () => {
3333

3434
test('Simple schema', async function () {
3535

36-
const content = '{"a": 42, "b": "hello", "c": false}';
36+
const content = '{"a": 42, "b": "hello", "c": false, "complex-description": false}';
3737
const schema: JSONSchema = {
3838
type: 'object',
3939
description: 'a very special object',
@@ -49,20 +49,27 @@ suite('JSON Hover', () => {
4949
'c': {
5050
type: 'boolean',
5151
description: 'C'
52-
}
52+
},
53+
'complex-description': {
54+
type: 'boolean',
55+
description: 'For example:\n\n<script>\n alert(1)\n</script>\n\n Test [1]'
56+
},
5357
}
5458
};
5559
await testComputeInfo(content, schema, { line: 0, character: 0 }).then((result) => {
56-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('a&nbsp;very&nbsp;special&nbsp;object')]);
60+
assert.deepEqual(result.contents, ['a&nbsp;very&nbsp;special&nbsp;object']);
5761
});
5862
await testComputeInfo(content, schema, { line: 0, character: 1 }).then((result) => {
59-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('A')]);
63+
assert.deepEqual(result.contents, ['A']);
6064
});
6165
await testComputeInfo(content, schema, { line: 0, character: 32 }).then((result) => {
62-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('C')]);
66+
assert.deepEqual(result.contents, ['C']);
67+
});
68+
await testComputeInfo(content, schema, { line: 0, character: 37 }).then((result) => {
69+
assert.deepEqual(result.contents, ['For&nbsp;example:\\\n\\\n\\<script\\>\\\n&nbsp;&nbsp;alert\\(1\\)\\\n\\</script\\>\\\n\\\n&nbsp;&nbsp;&nbsp;&nbsp;Test&nbsp;\\[1\\]']);
6370
});
6471
await testComputeInfo(content, schema, { line: 0, character: 7 }).then((result) => {
65-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('A')]);
72+
assert.deepEqual(result.contents, ['A']);
6673
});
6774
});
6875

@@ -89,13 +96,13 @@ suite('JSON Hover', () => {
8996
}]
9097
};
9198
await testComputeInfo(content, schema, { line: 0, character: 0 }).then((result) => {
92-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('a&nbsp;very&nbsp;special&nbsp;object')]);
99+
assert.deepEqual(result.contents, ['a&nbsp;very&nbsp;special&nbsp;object']);
93100
});
94101
await testComputeInfo(content, schema, { line: 0, character: 1 }).then((result) => {
95-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('A')]);
102+
assert.deepEqual(result.contents, ['A']);
96103
});
97104
await testComputeInfo(content, schema, { line: 0, character: 10 }).then((result) => {
98-
assert.deepEqual(result.contents, [MarkedString.fromPlainText('B\n\nIt\'s&nbsp;B')]);
105+
assert.deepEqual(result.contents, ['B\n\nIt\'s&nbsp;B']);
99106
});
100107
});
101108

0 commit comments

Comments
 (0)