@@ -583,6 +583,107 @@ Allowed Values:
583583* \`dog\`: Canis familiaris
584584* \`non\`
585585
586+ Source: [${ SCHEMA_ID } ](file:///${ SCHEMA_ID } )`
587+ ) ;
588+ } ) ;
589+
590+ it ( 'Hover hides title and source when disabled' , async ( ) => {
591+ ( ( ) => {
592+ languageSettingsSetup = new ServiceSetup ( )
593+ . withHover ( )
594+ . withHoverSettings ( {
595+ showTitle : false ,
596+ showSource : false ,
597+ } )
598+ . withIndentation ( ' ' )
599+ . withSchemaFileMatch ( {
600+ uri : 'http://google.com' ,
601+ fileMatch : [ 'bad-schema.yaml' ] ,
602+ } ) ;
603+ const {
604+ languageHandler : langHandler ,
605+ yamlSettings : settings ,
606+ telemetry : testTelemetry ,
607+ schemaProvider : testSchemaProvider ,
608+ } = setupLanguageService ( languageSettingsSetup . languageSettings ) ;
609+ languageHandler = langHandler ;
610+ yamlSettings = settings ;
611+ telemetry = testTelemetry ;
612+ schemaProvider = testSchemaProvider ;
613+ } ) ( ) ;
614+ schemaProvider . addSchema ( SCHEMA_ID , {
615+ type : 'object' ,
616+ title : 'Living being' ,
617+ properties : {
618+ animal : {
619+ type : 'string' ,
620+ description : 'should return this description' ,
621+ examples : [ 'cat' ] ,
622+ } ,
623+ } ,
624+ } ) ;
625+ const content = 'animal:\n ca|t|' ; // len: 13, pos: 12
626+ const result = await parseSetup ( content ) ;
627+
628+ assert . strictEqual ( MarkupContent . is ( result . contents ) , true ) ;
629+ assert . strictEqual ( ( result . contents as MarkupContent ) . kind , 'markdown' ) ;
630+ assert . strictEqual (
631+ ( result . contents as MarkupContent ) . value ,
632+ `should return this description
633+
634+ Example:
635+
636+ \`\`\`yaml
637+ cat
638+ \`\`\`
639+ `
640+ ) ;
641+ } ) ;
642+
643+ it ( 'Hover works when title and source explicitely enabled' , async ( ) => {
644+ ( ( ) => {
645+ languageSettingsSetup = new ServiceSetup ( )
646+ . withHover ( )
647+ . withSchemaFileMatch ( {
648+ uri : 'http://google.com' ,
649+ fileMatch : [ 'bad-schema.yaml' ] ,
650+ } )
651+ . withHoverSettings ( {
652+ showTitle : true ,
653+ showSource : true ,
654+ } ) ;
655+ const {
656+ languageHandler : langHandler ,
657+ yamlSettings : settings ,
658+ telemetry : testTelemetry ,
659+ schemaProvider : testSchemaProvider ,
660+ } = setupLanguageService ( languageSettingsSetup . languageSettings ) ;
661+ languageHandler = langHandler ;
662+ yamlSettings = settings ;
663+ telemetry = testTelemetry ;
664+ schemaProvider = testSchemaProvider ;
665+ } ) ( ) ;
666+ schemaProvider . addSchema ( SCHEMA_ID , {
667+ type : 'object' ,
668+ title : 'Living being' ,
669+ properties : {
670+ animal : {
671+ type : 'string' ,
672+ description : 'should return this description' ,
673+ } ,
674+ } ,
675+ } ) ;
676+ const content = 'animal:\n ca|t|' ; // len: 13, pos: 12
677+ const result = await parseSetup ( content ) ;
678+
679+ assert . strictEqual ( MarkupContent . is ( result . contents ) , true ) ;
680+ assert . strictEqual ( ( result . contents as MarkupContent ) . kind , 'markdown' ) ;
681+ assert . strictEqual (
682+ ( result . contents as MarkupContent ) . value ,
683+ `#### Living being
684+
685+ should return this description
686+
586687Source: [${ SCHEMA_ID } ](file:///${ SCHEMA_ID } )`
587688 ) ;
588689 } ) ;
0 commit comments