test: add test about path completion (#972)

This commit is contained in:
Myriad-Dreamin 2024-12-10 15:05:51 +08:00 committed by GitHub
parent 969cc6d339
commit f665d7c50c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 75 additions and 1 deletions

View file

@ -0,0 +1,6 @@
/// path: base.typ
#let aa() = 1;
-----
#import ""/* range -1..0 */

View file

@ -0,0 +1,32 @@
---
source: crates/tinymist-query/src/completion.rs
description: "Completion on \" (9..10)"
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/import_rel_path.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 17,
"label": "base.typ",
"sortText": "0",
"textEdit": {
"newText": "base.typ",
"range": {
"end": {
"character": 9,
"line": 0
},
"start": {
"character": 9,
"line": 0
}
}
}
}
]
}
]

View file

@ -0,0 +1,32 @@
---
source: crates/tinymist-query/src/completion.rs
description: "Completion on \" (30..31)"
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/string_path.typ
snapshot_kind: text
---
[
{
"isIncomplete": false,
"items": [
{
"kind": 17,
"label": "base.typ",
"sortText": "000",
"textEdit": {
"newText": "base.typ",
"range": {
"end": {
"character": 7,
"line": 1
},
"start": {
"character": 7,
"line": 1
}
}
}
}
]
}
]

View file

@ -0,0 +1,4 @@
/// path:base.typ
-----
/// contains: base.typ
#read(""/* range -1..0 */)

View file

@ -93,7 +93,7 @@ pub fn run_with_ctx<T>(
Some("example package (mock).".into()),
)]
});
ctx.test_completion_files(Vec::new);
ctx.test_completion_files(|| paths.clone());
ctx.test_files(|| paths);
f(&mut ctx, p)
}