update unit tests

This commit is contained in:
John Estropia
2021-02-21 10:59:55 +09:00
parent d7b852fca4
commit d13b0cfabb
3 changed files with 19 additions and 5 deletions

View File

@@ -41,11 +41,14 @@ final class SectionByTests: XCTestCase {
let sectionBy = SectionBy<NSManagedObject>("key")
XCTAssertEqual(sectionBy.sectionKeyPath, "key")
XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key")
XCTAssertNil(sectionBy.sectionIndexTransformer("key"))
}
do {
let sectionBy = SectionBy<NSManagedObject>("key") { $0.flatMap { "\($0):suffix" } }
let sectionBy = SectionBy<NSManagedObject>(
"key",
sectionIndexTransformer: { $0.flatMap { "\($0):suffix" } }
)
XCTAssertEqual(sectionBy.sectionKeyPath, "key")
XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key:suffix")
XCTAssertNil(sectionBy.sectionIndexTransformer(nil))

View File

@@ -60,7 +60,12 @@ public final class CSSectionBy: NSObject {
@objc
public static func keyPath(_ sectionKeyPath: KeyPathString, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy {
return self.init(SectionBy<NSManagedObject>(sectionKeyPath, sectionIndexTransformer))
return self.init(
SectionBy<NSManagedObject>(
sectionKeyPath,
sectionIndexTransformer: sectionIndexTransformer
)
)
}
@@ -101,6 +106,9 @@ extension SectionBy {
fileprivate func downcast() -> SectionBy<NSManagedObject> {
return SectionBy<NSManagedObject>(self.sectionKeyPath, self.sectionIndexTransformer)
return SectionBy<NSManagedObject>(
self.sectionKeyPath,
sectionIndexTransformer: self.sectionIndexTransformer
)
}
}

View File

@@ -259,7 +259,10 @@ extension From {
return .init(
from: self,
sectionBy: .init(sectionKeyPath, sectionIndexTransformer),
sectionBy: .init(
sectionKeyPath,
sectionIndexTransformer: sectionIndexTransformer
),
fetchClauses: []
)
}