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") let sectionBy = SectionBy<NSManagedObject>("key")
XCTAssertEqual(sectionBy.sectionKeyPath, "key") XCTAssertEqual(sectionBy.sectionKeyPath, "key")
XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key") XCTAssertNil(sectionBy.sectionIndexTransformer("key"))
} }
do { 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.sectionKeyPath, "key")
XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key:suffix") XCTAssertEqual(sectionBy.sectionIndexTransformer("key"), "key:suffix")
XCTAssertNil(sectionBy.sectionIndexTransformer(nil)) XCTAssertNil(sectionBy.sectionIndexTransformer(nil))

View File

@@ -60,7 +60,12 @@ public final class CSSectionBy: NSObject {
@objc @objc
public static func keyPath(_ sectionKeyPath: KeyPathString, sectionIndexTransformer: @escaping (_ sectionName: String?) -> String?) -> CSSectionBy { 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> { 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( return .init(
from: self, from: self,
sectionBy: .init(sectionKeyPath, sectionIndexTransformer), sectionBy: .init(
sectionKeyPath,
sectionIndexTransformer: sectionIndexTransformer
),
fetchClauses: [] fetchClauses: []
) )
} }