Update file structure tests

This commit is contained in:
Aleksey Kladov 2020-07-01 17:59:44 +02:00
parent 14bf5bb7ee
commit 53e3a7aeb4

View file

@ -173,12 +173,19 @@ fn structure_node(node: &SyntaxNode) -> Option<StructureNode> {
#[cfg(test)]
mod tests {
use expect::{expect, Expect};
use super::*;
use insta::assert_debug_snapshot;
fn check(ra_fixture: &str, expect: Expect) {
let file = SourceFile::parse(ra_fixture).ok().unwrap();
let structure = file_structure(&file);
expect.assert_debug_eq(&structure)
}
#[test]
fn test_file_structure() {
let file = SourceFile::parse(
check(
r#"
struct Foo {
x: i32
@ -223,12 +230,7 @@ fn obsolete() {}
#[deprecated(note = "for awhile")]
fn very_obsolete() {}
"#,
)
.ok()
.unwrap();
let structure = file_structure(&file);
assert_debug_snapshot!(structure,
@r###"
expect![[r#"
[
StructureNode {
parent: None,
@ -432,7 +434,7 @@ fn very_obsolete() {}
deprecated: true,
},
]
"###
"#]],
);
}
}