summaryrefslogtreecommitdiff
path: root/support/texlab/crates/texlab/tests/lsp/text_document/folding_range.rs
blob: 063ca7533daefff77153c1def2e45539c62ac0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use insta::assert_json_snapshot;
use lsp_types::{
    request::FoldingRangeRequest, ClientCapabilities, FoldingRange, FoldingRangeParams,
};

use crate::fixture::TestBed;

fn find_foldings(fixture: &str) -> Vec<FoldingRange> {
    let test_bed = TestBed::new(fixture).unwrap();

    test_bed.initialize(ClientCapabilities::default()).unwrap();

    let text_document = test_bed.cursor().unwrap().text_document;
    test_bed
        .client()
        .send_request::<FoldingRangeRequest>(FoldingRangeParams {
            text_document,
            work_done_progress_params: Default::default(),
            partial_result_params: Default::default(),
        })
        .unwrap()
        .unwrap_or_default()
}

#[test]
fn latex() {
    assert_json_snapshot!(find_foldings(
        r#"
%! main.tex
\begin{document}
    \section{Foo}
    foo
    \subsection{Bar}
    bar
    \section{Baz}
    baz
    \section{Qux}
\end{document}
|"#
    ));
}

#[test]
fn bibtex() {
    assert_json_snapshot!(find_foldings(
        r#"
%! main.bib
some junk
here

@article{foo,
    author = {bar},
    title = {baz}
}

@string{foo = "bar"}

@comment{foo,
    author = {bar},
    title = {baz}
}

@preamble{"foo"}
|"#
    ));
}