Skip to content

Commit

Permalink
Fixed tree tests in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
JetpackDuba committed Sep 1, 2024
1 parent 70941c5 commit 5a24c13
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/test/kotlin/com/jetpackduba/gitnuro/ui/tree_files/TreeTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jetpackduba.gitnuro.ui.tree_files

import com.jetpackduba.gitnuro.system.systemSeparator
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
Expand All @@ -25,48 +26,52 @@ class TreeTest {

@Test
fun `test entriesToTreeEntry with multiple file entries`() {
val entries = listOf("dir1/file1.txt", "dir2/file2.txt", "dir3/file3.txt")
val entries = listOf(
"dir1${systemSeparator}file1.txt",
"dir2${systemSeparator}file2.txt",
"dir3${systemSeparator}file3.txt",
)
val treeContractedDirs = emptyList<String>()
val result = entriesToTreeEntry(entries, treeContractedDirs) { it }
val expected = listOf(
TreeItem.Dir(true, "dir1", "dir1", 0),
TreeItem.File("dir1/file1.txt", "file1.txt", "dir1/file1.txt", 1),
TreeItem.File("dir1${systemSeparator}file1.txt", "file1.txt", "dir1${systemSeparator}file1.txt", 1),
TreeItem.Dir(true, "dir2", "dir2", 0),
TreeItem.File("dir2/file2.txt", "file2.txt", "dir2/file2.txt", 1),
TreeItem.File("dir2${systemSeparator}file2.txt", "file2.txt", "dir2${systemSeparator}file2.txt", 1),
TreeItem.Dir(true, "dir3", "dir3", 0),
TreeItem.File("dir3/file3.txt", "file3.txt", "dir3/file3.txt", 1)
TreeItem.File("dir3${systemSeparator}file3.txt", "file3.txt", "dir3${systemSeparator}file3.txt", 1)
)
assertEquals(expected, result)
}

@Test
fun `test entriesToTreeEntry with similar names`() {
val entries = listOf(
"webpack/webpack.config2.ts",
"webpack/webpack.config.ts",
"webpack${systemSeparator}webpack.config2.ts",
"webpack${systemSeparator}webpack.config.ts",
"webpack-plugin.ts",
"dir1/file3.txt"
"dir1${systemSeparator}file3.txt"
)
val treeContractedDirs = emptyList<String>()
val result = entriesToTreeEntry(entries, treeContractedDirs) { it }
val expected = listOf(
TreeItem.Dir(true, "dir1", "dir1", 0),
TreeItem.File("dir1/file3.txt", "file3.txt", "dir1/file3.txt", 1),
TreeItem.File("dir1${systemSeparator}file3.txt", "file3.txt", "dir1${systemSeparator}file3.txt", 1),
TreeItem.Dir(true, "webpack", "webpack", 0),
TreeItem.File("webpack/webpack.config.ts", "webpack.config.ts", "webpack/webpack.config.ts", 1),
TreeItem.File("webpack/webpack.config2.ts", "webpack.config2.ts", "webpack/webpack.config2.ts", 1),
TreeItem.File("webpack${systemSeparator}webpack.config.ts", "webpack.config.ts", "webpack${systemSeparator}webpack.config.ts", 1),
TreeItem.File("webpack${systemSeparator}webpack.config2.ts", "webpack.config2.ts", "webpack${systemSeparator}webpack.config2.ts", 1),
TreeItem.File("webpack-plugin.ts", "webpack-plugin.ts", "webpack-plugin.ts", 0)
)
assertEquals(expected, result)
}

@Test
fun `test entriesToTreeEntry with contracted directories`() {
fun `test test entriesToTreeEntry with similar names with contracted directories`() {
val entries = listOf(
"webpack/webpack.config2.ts",
"webpack/webpack.config.ts",
"webpack${systemSeparator}webpack.config2.ts",
"webpack${systemSeparator}webpack.config.ts",
"webpack-plugin.ts",
"dir1/file3.txt"
"dir1${systemSeparator}file3.txt"
)
val treeContractedDirs = listOf<String>("webpack", "dir1")
val result = entriesToTreeEntry(entries, treeContractedDirs) { it }
Expand Down

0 comments on commit 5a24c13

Please sign in to comment.