mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 22:30:34 +01:00
update unit tests
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,7 +259,10 @@ extension From {
|
||||
|
||||
return .init(
|
||||
from: self,
|
||||
sectionBy: .init(sectionKeyPath, sectionIndexTransformer),
|
||||
sectionBy: .init(
|
||||
sectionKeyPath,
|
||||
sectionIndexTransformer: sectionIndexTransformer
|
||||
),
|
||||
fetchClauses: []
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user