aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers/hover_test.js
diff options
context:
space:
mode:
authorGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
committerGravatar Moon Flower <moonflower@elhenney.local> 2026-10-12 08:46:23 +0330
commitecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 (patch)
tree70e0af76a1b13affff7c6cc8aac7b3e6ef960478 /tests/drivers/hover_test.js
a
Diffstat (limited to 'tests/drivers/hover_test.js')
-rw-r--r--tests/drivers/hover_test.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/drivers/hover_test.js b/tests/drivers/hover_test.js
new file mode 100644
index 0000000..10af643
--- /dev/null
+++ b/tests/drivers/hover_test.js
@@ -0,0 +1,23 @@
+// protocol conversion checks. run with node tests/drivers/hover_test.js.
+const assert = require('assert');
+const { hoverContents } = require('../../editors/vscode/client/hover');
+class MarkdownString {
+ constructor() { this.value = ''; this.calls = []; }
+ appendMarkdown(value) { this.calls.push('markdown'); this.value += value; return this; }
+ appendText(value) { this.calls.push('text'); this.value += value; return this; }
+ appendCodeblock(value, language) { this.calls.push('code'); this.value += '\n```' + language + '\n' + value + '\n```\n'; return this; }
+}
+const api = { MarkdownString };
+const markdown = '```zc\nint add(int a, int b)\n```\n\nAdds **two** numbers.';
+const md = hoverContents(api, { kind: 'markdown', value: markdown })[0];
+assert.strictEqual(md.value, markdown);
+assert.deepStrictEqual(md.calls, ['markdown']);
+assert.strictEqual(md.isTrusted, false);
+assert.strictEqual(md.supportHtml, false);
+assert.deepStrictEqual(hoverContents(api, { kind: 'plaintext', value: '*literal*' })[0].calls, ['text']);
+const legacy = hoverContents(api, { language: 'zc', value: 'int x;' })[0];
+assert.match(legacy.value, /```zc\nint x;\n```/);
+assert.deepStrictEqual(legacy.calls, ['code']);
+assert.strictEqual(hoverContents(api, ['**Doc**', { language: 'zc', value: 'fn main()' }]).length, 2);
+for (const contents of [null, undefined, '', [], {}, { value: 123 }]) assert.deepStrictEqual(hoverContents(api, contents), []);
+console.log('ok hover conversion preserves Markdown, plaintext, code, and arrays');