mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 09:52:27 +00:00
test: add tests about signature help (#917)
This commit is contained in:
parent
1a41dfeb2d
commit
982c430338
7 changed files with 89 additions and 0 deletions
|
@ -0,0 +1,3 @@
|
|||
#let f(x) = x;
|
||||
|
||||
#(f(/* position */));
|
|
@ -0,0 +1 @@
|
|||
#(math.underline(/* position */));
|
|
@ -0,0 +1 @@
|
|||
$underline(/* position */)$
|
|
@ -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:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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
|
|
@ -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:"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -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));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue