File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ const OutputMode = {
1313 hidden : "hidden" ,
1414} ;
1515
16+ // placeholder for the empty output value
17+ const PLACEHOLDER = "ok" ;
18+
1619const template = document . createElement ( "template" ) ;
1720template . innerHTML = `
1821<a href="#close">✕</a>
@@ -24,7 +27,7 @@ template.innerHTML = `
2427const builders = {
2528 // returns the result as a text node.
2629 [ OutputMode . text ] : ( result ) => {
27- const text = result . stdout || result . stderr ;
30+ const text = result . stdout || result . stderr || PLACEHOLDER ;
2831 return document . createTextNode ( text ) ;
2932 } ,
3033
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ async function runTests() {
5555 await testOutputModeIframe ( ) ;
5656 await testOutputModeDOM ( ) ;
5757 await testOutputModeHidden ( ) ;
58+ await testOutputPlaceholder ( ) ;
5859
5960 await testTemplate ( ) ;
6061 await testTemplateChange ( ) ;
@@ -743,6 +744,22 @@ async function testOutputModeHidden() {
743744 } ) ;
744745}
745746
747+ async function testOutputPlaceholder ( ) {
748+ return new Promise ( ( resolve , reject ) => {
749+ t . log ( "testOutputPlaceholder..." ) ;
750+ const ui = createSnippet ( `
751+ <pre><code>const a = 42;</code></pre>
752+ <codapi-snippet engine="browser" sandbox="javascript" output-mode="text">
753+ </codapi-snippet>
754+ ` ) ;
755+ ui . snip . addEventListener ( "result" , ( event ) => {
756+ t . assert ( "output" , ui . output . out . innerHTML == "ok" ) ;
757+ resolve ( ) ;
758+ } ) ;
759+ ui . toolbar . run . click ( ) ;
760+ } ) ;
761+ }
762+
746763async function testTemplate ( ) {
747764 return new Promise ( ( resolve , reject ) => {
748765 t . log ( "testTemplate..." ) ;
You can’t perform that action at this time.
0 commit comments