Fixed tree tests in windows

This commit is contained in:
Abdelilah El Aissaoui 2024-09-01 14:45:54 +02:00
parent 70941c53f1
commit 5a24c13628
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -1,5 +1,6 @@
package com.jetpackduba.gitnuro.ui.tree_files 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.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
@ -25,16 +26,20 @@ class TreeTest {
@Test @Test
fun `test entriesToTreeEntry with multiple file entries`() { 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 treeContractedDirs = emptyList<String>()
val result = entriesToTreeEntry(entries, treeContractedDirs) { it } val result = entriesToTreeEntry(entries, treeContractedDirs) { it }
val expected = listOf( val expected = listOf(
TreeItem.Dir(true, "dir1", "dir1", 0), 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.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.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) assertEquals(expected, result)
} }
@ -42,31 +47,31 @@ class TreeTest {
@Test @Test
fun `test entriesToTreeEntry with similar names`() { fun `test entriesToTreeEntry with similar names`() {
val entries = listOf( val entries = listOf(
"webpack/webpack.config2.ts", "webpack${systemSeparator}webpack.config2.ts",
"webpack/webpack.config.ts", "webpack${systemSeparator}webpack.config.ts",
"webpack-plugin.ts", "webpack-plugin.ts",
"dir1/file3.txt" "dir1${systemSeparator}file3.txt"
) )
val treeContractedDirs = emptyList<String>() val treeContractedDirs = emptyList<String>()
val result = entriesToTreeEntry(entries, treeContractedDirs) { it } val result = entriesToTreeEntry(entries, treeContractedDirs) { it }
val expected = listOf( val expected = listOf(
TreeItem.Dir(true, "dir1", "dir1", 0), 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.Dir(true, "webpack", "webpack", 0),
TreeItem.File("webpack/webpack.config.ts", "webpack.config.ts", "webpack/webpack.config.ts", 1), TreeItem.File("webpack${systemSeparator}webpack.config.ts", "webpack.config.ts", "webpack${systemSeparator}webpack.config.ts", 1),
TreeItem.File("webpack/webpack.config2.ts", "webpack.config2.ts", "webpack/webpack.config2.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) TreeItem.File("webpack-plugin.ts", "webpack-plugin.ts", "webpack-plugin.ts", 0)
) )
assertEquals(expected, result) assertEquals(expected, result)
} }
@Test @Test
fun `test entriesToTreeEntry with contracted directories`() { fun `test test entriesToTreeEntry with similar names with contracted directories`() {
val entries = listOf( val entries = listOf(
"webpack/webpack.config2.ts", "webpack${systemSeparator}webpack.config2.ts",
"webpack/webpack.config.ts", "webpack${systemSeparator}webpack.config.ts",
"webpack-plugin.ts", "webpack-plugin.ts",
"dir1/file3.txt" "dir1${systemSeparator}file3.txt"
) )
val treeContractedDirs = listOf<String>("webpack", "dir1") val treeContractedDirs = listOf<String>("webpack", "dir1")
val result = entriesToTreeEntry(entries, treeContractedDirs) { it } val result = entriesToTreeEntry(entries, treeContractedDirs) { it }