Skip to content

Commit 45855ac

Browse files
authored
New name validator tests (#161)
Signed-off-by: Milen Pivchev <milen.pivchev@gmail.com>
1 parent f8df227 commit 45855ac

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Tests/NextcloudKitUnitTests/FileNameValidatorUnitTests.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,31 @@ class FileNameValidatorUnitTests: XCTestCase {
101101

102102
func testFilePathWithNestedFolder() {
103103
let folderPath = "validFolder/secondValidFolder/CON"
104+
let filePaths = ["file1.txt", "file2.doc", "file3."]
105+
106+
let result = fileNameValidator.checkFolderPath(folderPath)
107+
XCTAssertFalse(result)
108+
109+
filePaths.forEach { path in
110+
let result = fileNameValidator.checkFileName(path)
111+
112+
if path == "file3." {
113+
XCTAssertNotNil(result?.errorDescription)
114+
} else {
115+
XCTAssertNil(result?.errorDescription)
116+
}
117+
}
118+
}
119+
120+
func testOnlyFolderPath() {
121+
let folderPath = "/A1/Aaaww/W/C2/"
122+
123+
let result = fileNameValidator.checkFolderPath(folderPath)
124+
XCTAssertTrue(result)
125+
}
126+
127+
func testOnlyFolderPathWithOneReservedName() {
128+
let folderPath = "/A1/Aaaww/CON/W/C2/"
104129

105130
let result = fileNameValidator.checkFolderPath(folderPath)
106131
XCTAssertFalse(result)

0 commit comments

Comments
 (0)