File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ sandboxTest('js context', async ({ sandbox }) => {
4040} )
4141
4242sandboxTest ( 'js cwd' , async ( { sandbox } ) => {
43- const result = await sandbox . runCode ( 'process.cwd()' , { language : "deno})
43+ const result = await sandbox . runCode ( 'process.cwd()' , { language : "deno" } )
4444 expect ( result . results [ 0 ] . text ) . toEqual ( '/home/user' )
4545
4646 const ctx = await sandbox . createCodeContext ( { cwd : '/home' , language : "deno" } )
@@ -59,3 +59,22 @@ subtract(1, 2)
5959
6060 expect ( result . results [ 0 ] . text ) . toEqual ( '-1' )
6161} )
62+
63+ sandboxTest ( 'test display' , async ( { sandbox } ) => {
64+ const result = await sandbox . runCode ( `
65+ {
66+ [Symbol.for("Jupyter.display")]() {
67+ return {
68+ // Plain text content
69+ "text/plain": "Hello world!",
70+
71+ // HTML output
72+ "text/html": "<h1>Hello world!</h1>",
73+ }
74+ }
75+ }
76+ ` , { language : "deno" } )
77+
78+ expect ( result . results [ 0 ] . html ) . toBe ( '<h1>Hello world!</h1>' )
79+ expect ( result . results [ 0 ] . text ) . toBe ( 'Hello world!' )
80+ } )
Original file line number Diff line number Diff line change @@ -66,3 +66,22 @@ async def test_typescript(async_sandbox: AsyncSandbox):
6666 language = "deno" ,
6767 )
6868 assert execution .results [0 ].text == "-1"
69+
70+
71+ async def test_display (async_sandbox : AsyncSandbox ):
72+ code = """
73+ {
74+ [Symbol.for("Jupyter.display")]() {
75+ return {
76+ // Plain text content
77+ "text/plain": "Hello world!",
78+
79+ // HTML output
80+ "text/html": "<h1>Hello world!</h1>",
81+ }
82+ }
83+ }
84+ """
85+ execution = await async_sandbox .run_code (code , language = "deno" )
86+ assert execution .results [0 ].text == "Hello world!"
87+ assert execution .results [0 ].html == "<h1>Hello world!</h1>"
You can’t perform that action at this time.
0 commit comments