@@ -58,6 +58,28 @@ async function testAsciidoctorWebViewConverter (
58
58
assert . strictEqual ( html , expected )
59
59
}
60
60
61
+ async function testAsciidoctorWebViewConverterStandalone (
62
+ input : string ,
63
+ antoraDocumentContext : AntoraDocumentContext | undefined ,
64
+ expected : string ,
65
+ root : vscode . Uri ,
66
+ pathSegments : string [ ]
67
+ ) {
68
+ const file = await vscode . workspace . openTextDocument ( vscode . Uri . joinPath ( root , ...pathSegments ) )
69
+ const asciidoctorWebViewConverter = new AsciidoctorWebViewConverter (
70
+ file ,
71
+ new TestWebviewResourceProvider ( ) ,
72
+ 2 ,
73
+ false ,
74
+ new TestAsciidocContributions ( ) ,
75
+ new AsciidocPreviewConfigurationManager ( ) . loadAndCacheConfiguration ( file . uri ) ,
76
+ antoraDocumentContext ,
77
+ undefined
78
+ )
79
+ const html = processor . convert ( input , { converter : asciidoctorWebViewConverter , standalone : true } )
80
+ html . includes ( expected )
81
+ }
82
+
61
83
suite ( 'AsciidoctorWebViewConverter' , async ( ) => {
62
84
const createdFiles : vscode . Uri [ ] = [ ]
63
85
suiteSetup ( async ( ) => {
@@ -124,9 +146,32 @@ link:help.adoc[]
124
146
<p><a href="full.adoc" class="bare action button" data-href="full.adoc">full.adoc</a></p>
125
147
</div>` ,
126
148
} ,
149
+ {
150
+ title : 'Should not add role doc to content when no Antora context is provided' ,
151
+ filePath : [ 'asciidoctorWebViewConverterTest.adoc' ] ,
152
+ input : '= Test Document' ,
153
+ antoraDocumentContext : undefined , // Antora not enabled
154
+ expected : '<div id="content">' ,
155
+ standalone : true ,
156
+ } ,
157
+ {
158
+ title : 'Add role doc to content when Antora context is provided' ,
159
+ filePath : [ 'docs' , 'modules' , 'ROOT' , 'pages' , 'dummy.adoc' ] ,
160
+ input : '= Test Document' ,
161
+ antoraDocumentContext : createAntoraDocumentContextStub ( undefined ) ,
162
+ expected : '<div id="content" class="doc">' ,
163
+ standalone : true ,
164
+ } ,
165
+
127
166
]
128
167
129
168
for ( const testCase of testCases ) {
130
- test ( testCase . title , async ( ) => testAsciidoctorWebViewConverter ( testCase . input , testCase . antoraDocumentContext , testCase . expected , workspaceUri , testCase . filePath ) )
169
+ if ( testCase . standalone ) {
170
+ test ( testCase . title , async ( ) => testAsciidoctorWebViewConverterStandalone (
171
+ testCase . input , testCase . antoraDocumentContext , testCase . expected , workspaceUri , testCase . filePath
172
+ ) )
173
+ } else {
174
+ test ( testCase . title , async ( ) => testAsciidoctorWebViewConverter ( testCase . input , testCase . antoraDocumentContext , testCase . expected , workspaceUri , testCase . filePath ) )
175
+ }
131
176
}
132
177
} )
0 commit comments