Support EditorConfig for online browser/editor.

This commit is contained in:
KOUNOIKE Yuusuke
2018-04-21 10:33:29 +09:00
parent c1d6839c18
commit e350126794
8 changed files with 342 additions and 16 deletions

View File

@@ -0,0 +1,38 @@
package gitbucket.core.util
import org.scalatest.FunSuite
import GitSpecUtil._
class EditorConfigUtilSpec extends FunSuite {
val simpleConfig =
"""[*.txt]
|indent_style = tab
|indent_size = 4""".stripMargin
test("no EditorConfig file") {
withTestRepository { git =>
createFile(git, "master", "README.md", "body", message = "commit1")
val props = EditorConfigUtil.readProperties(git, "master", "test.txt")
assert(EditorConfigUtil.getTabWidth(props) == 8)
assert(EditorConfigUtil.getUseSoftTabs(props) == false)
assert(EditorConfigUtil.getNewLineMode(props) == "auto")
val subdirProps = EditorConfigUtil.readProperties(git, "master", "dir1/dir2/dir3/dir4/test.txt")
assert(EditorConfigUtil.getTabWidth(subdirProps) == 8)
assert(EditorConfigUtil.getUseSoftTabs(subdirProps) == false)
assert(EditorConfigUtil.getNewLineMode(subdirProps) == "auto")
}
}
test("simple EditorConfig") {
withTestRepository { git =>
createFile(git, "master", ".editorconfig", simpleConfig, message = "commit1")
val props = EditorConfigUtil.readProperties(git, "master", "test.txt")
assert(EditorConfigUtil.getTabWidth(props) == 4)
val subdirProps = EditorConfigUtil.readProperties(git, "master", "dir1/dir2/dir3/dir4/test.txt")
assert(EditorConfigUtil.getTabWidth(subdirProps) == 4)
}
}
}