@@ -795,55 +795,56 @@ public void ScriptTagHelper_RendersImportMap_FromEndpoint()
795795 }
796796
797797 [ Fact ]
798- public void ScriptTagHelper_PreservesExplicitImportMapContent_WhenNoImportMapDefinition ( )
798+ public async Task ScriptTagHelper_PreservesExplicitImportMapContent_WhenUserProvidesContent ( )
799799 {
800800 // Arrange - this simulates the user's scenario where they provide explicit importmap content
801- // without using asp-importmap attribute
802801 var context = MakeTagHelperContext (
803802 attributes : new TagHelperAttributeList
804803 {
805804 new TagHelperAttribute ( "type" , "importmap" ) ,
806805 } ) ;
807806
808807 var output = MakeTagHelperOutput ( "script" , attributes : new TagHelperAttributeList ( ) ) ;
808+ // Simulate user providing explicit content
809+ output . Content . SetHtmlContent ( @"{""imports"":{""jquery"":""https://code.jquery.com/jquery.js""}}" ) ;
809810
810811 var helper = GetHelper ( ) ;
811812 helper . Type = "importmap" ;
812- // No endpoint with ImportMapDefinition and no asp-importmap attribute
813- // This should NOT suppress the output, allowing user content to render
813+ // No endpoint with ImportMapDefinition - this should NOT suppress the output
814+ // since user provided explicit content
814815
815816 // Act
816- helper . Process ( context , output ) ;
817+ await helper . ProcessAsync ( context , output ) ;
817818
818819 // Assert
819820 Assert . Equal ( "script" , output . TagName ) ; // Tag should not be suppressed
820821 Assert . Equal ( "importmap" , output . Attributes [ "type" ] . Value ) ;
821- // The output should not be suppressed, allowing user's explicit content to render
822- Assert . False ( output . IsContentModified ) ; // Content should remain as user provided
822+ // The user's explicit content should be preserved
823+ Assert . Equal ( @"{""imports"":{""jquery"":""https://code.jquery.com/jquery.js""}}" , output . Content . GetContent ( ) ) ;
823824 }
824825
825826 [ Fact ]
826- public void ScriptTagHelper_SuppressesOutput_WhenAspImportMapAttributeUsedButNoDefinition ( )
827+ public async Task ScriptTagHelper_SuppressesOutput_WhenNoContentAndNoImportMapDefinition ( )
827828 {
828- // Arrange - this simulates using asp- importmap attribute but having no ImportMapDefinition
829+ // Arrange - this simulates an empty importmap script with no definition
829830 var context = MakeTagHelperContext (
830831 attributes : new TagHelperAttributeList
831832 {
832833 new TagHelperAttribute ( "type" , "importmap" ) ,
833- new TagHelperAttribute ( "asp-importmap" , null ) , // asp-importmap used but no value
834834 } ) ;
835835
836836 var output = MakeTagHelperOutput ( "script" , attributes : new TagHelperAttributeList ( ) ) ;
837+ // No content provided
837838
838839 var helper = GetHelper ( ) ;
839840 helper . Type = "importmap" ;
840- // No endpoint with ImportMapDefinition but asp-importmap attribute is present
841- // This should suppress the output since it was intended to be auto-generated
841+ // No endpoint with ImportMapDefinition and no explicit content
842+ // This should suppress the output since there's nothing to render
842843
843844 // Act
844- helper . Process ( context , output ) ;
845+ await helper . ProcessAsync ( context , output ) ;
845846
846- // Assert - output should be suppressed when asp-importmap is used but no definition found
847+ // Assert - output should be suppressed when no content and no definition
847848 Assert . Null ( output . TagName ) ; // Tag should be suppressed
848849 }
849850
0 commit comments