test: add tests about signature help (#917)

This commit is contained in:
Myriad-Dreamin 2024-11-30 22:50:58 +08:00 committed by GitHub
parent 1a41dfeb2d
commit 982c430338
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 89 additions and 0 deletions

View file

@ -0,0 +1,3 @@
#let f(x) = x;
#(f(/* position */));

View file

@ -0,0 +1 @@
#(math.underline(/* position */));

View file

@ -0,0 +1 @@
$underline(/* position */)$

View file

@ -0,0 +1,28 @@
---
source: crates/tinymist-query/src/signature_help.rs
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/signature_help/base.typ
snapshot_kind: text
---
{
"activeSignature": 0,
"signatures": [
{
"activeParameter": 0,
"documentation": {
"kind": "markdown",
"value": ""
},
"label": "f(x: any) -> any",
"parameters": [
{
"documentation": {
"kind": "markdown",
"value": ""
},
"label": "x:"
}
]
}
]
}

View file

@ -0,0 +1,7 @@
---
source: crates/tinymist-query/src/signature_help.rs
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/signature_help/builtin.typ
snapshot_kind: text
---
null

View file

@ -0,0 +1,28 @@
---
source: crates/tinymist-query/src/signature_help.rs
expression: "JsonRepr::new_redacted(result, &REDACT_LOC)"
input_file: crates/tinymist-query/src/fixtures/signature_help/builtin2.typ
snapshot_kind: text
---
{
"activeSignature": 0,
"signatures": [
{
"activeParameter": 0,
"documentation": {
"kind": "markdown",
"value": "A horizontal line under content.\n\n```example\n$ underline(1 + 2 + ... + 5) $\n```"
},
"label": "underline(body: content) -> underline",
"parameters": [
{
"documentation": {
"kind": "markdown",
"value": "The content above the line."
},
"label": "body:"
}
]
}
]
}

View file

@ -132,3 +132,24 @@ fn markdown_docs(docs: &str) -> Documentation {
value: docs.to_owned(),
})
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests::*;
#[test]
fn test() {
snapshot_testing("signature_help", &|ctx, path| {
let source = ctx.source_by_path(&path).unwrap();
let request = SignatureHelpRequest {
path: path.clone(),
position: find_test_position(&source),
};
let result = request.request(ctx);
assert_snapshot!(JsonRepr::new_redacted(result, &REDACT_LOC));
});
}
}