Skip to content

Commit 7c42c43

Browse files
committed
Add display test
1 parent 646ea1e commit 7c42c43

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

js/tests/languages/deno.test.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sandboxTest('js context', async ({ sandbox }) => {
4040
})
4141

4242
sandboxTest('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+
})

python/tests/languages/test_deno.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff 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>"

0 commit comments

Comments
 (0)