-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3278 from Hannah-Sten/3273-structure-view
3273 Fix structure view nesting
- Loading branch information
Showing
2 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
test/nl/hannahsten/texifyidea/structure/latex/LatexStructureViewElementTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package nl.hannahsten.texifyidea.structure.latex | ||
|
||
import com.intellij.testFramework.fixtures.BasePlatformTestCase | ||
import nl.hannahsten.texifyidea.file.LatexFileType | ||
|
||
class LatexStructureViewElementTest : BasePlatformTestCase() { | ||
fun `test that item is added to correct level when it is more than one level higher than the previous element`() { | ||
myFixture.configureByText( | ||
LatexFileType, | ||
""" | ||
\section{s} | ||
\subsection{ss1} | ||
\subsubsection{sss} | ||
\paragraph{p} | ||
\subsection{ss2} | ||
""".trimIndent() | ||
) | ||
|
||
myFixture.testStructureView { component -> | ||
val documentChildren = (component.treeModel as LatexStructureViewModel).root.children | ||
// \section{s1} is the only child element of the document class element. | ||
assertEquals(1, documentChildren.size) | ||
// \subsection{ss1} | ||
// ... | ||
// \subsection{ss2} | ||
assertEquals( | ||
listOf("\\subsection{ss1}", "\\subsection{ss2}"), | ||
documentChildren[0].children.map { (it as LatexStructureViewCommandElement).value.text } | ||
) | ||
} | ||
} | ||
|
||
fun `test that item is added to tree when all items before where of lower level`() { | ||
myFixture.configureByText( | ||
LatexFileType, | ||
""" | ||
\subsubsection{sss} | ||
\paragraph{p} | ||
\subsection{ss} | ||
""".trimIndent() | ||
) | ||
|
||
myFixture.testStructureView { component -> | ||
val documentChildren = (component.treeModel as LatexStructureViewModel).root.children | ||
// \subsubsection{sss} | ||
// \paragraph{p} | ||
// \subsection{ss} | ||
assertEquals( | ||
listOf("\\subsubsection{sss}", "\\subsection{ss}"), | ||
documentChildren.map { (it as LatexStructureViewCommandElement).value.text } | ||
) | ||
} | ||
} | ||
} |