55
66import * 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
1010suite ( '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 very special object' ) ] ) ;
60+ assert . deepEqual ( result . contents , [ 'a very special 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 example:\\\n\\\n\\<script\\>\\\n alert\\(1\\)\\\n\\</script\\>\\\n\\\n Test \\[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 very special object' ) ] ) ;
99+ assert . deepEqual ( result . contents , [ 'a very special 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 B' ) ] ) ;
105+ assert . deepEqual ( result . contents , [ 'B\n\nIt\'s B' ] ) ;
99106 } ) ;
100107 } ) ;
101108
0 commit comments