mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-29 22:01:56 +02:00
update unit tests
This commit is contained in:
@@ -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))
|
||||||
|
|||||||
@@ -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
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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: []
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user