Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ import XCTest
@testable import CacheStoreDemo

class CacheStoreDemoTests: XCTestCase {
override func setUp() {
TestStoreFailure.handler = XCTFail
}

func testExample_success() throws {
let store = TestStore(
initialValues: [
Expand Down
2 changes: 1 addition & 1 deletion Sources/CacheStore/Stores/Store.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public class Store<Key: Hashable, Action, Dependency>: ObservableObject, ActionH

// MARK: - Void Dependency

public extension Store {
public extension Store where Dependency == Void {
/// Creates a `ScopedStore`
func scope<ScopedKey: Hashable, ScopedAction>(
keyTransformation: c.BiDirectionalTransformation<Key?, ScopedKey?>,
Expand Down
15 changes: 2 additions & 13 deletions Sources/CacheStore/Stores/TestStore.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#if DEBUG
import CustomDump
import Foundation
import XCTestDynamicOverlay

/// Facade typealias for XCTFail without importing XCTest
public typealias FailureHandler = (_ message: String, _ file: StaticString, _ line: UInt) -> Void

/// Static object to provide the `FailureHandler` to any `TestStore`
public enum TestStoreFailure {
public static var handler: FailureHandler!
public static var handler: FailureHandler = XCTestDynamicOverlay.XCTFail
}

/// Testable `Store` where you can send and receive actions while expecting the changes
Expand Down Expand Up @@ -42,18 +43,6 @@ public class TestStore<Key: Hashable, Action, Dependency> {
file: StaticString = #filePath,
line: UInt = #line
) {
assert(
TestStoreFailure.handler != nil,
"""
Set `TestStoreFailure.handler`

override func setUp() {
TestStoreFailure.handler = XCTFail
}

"""
)

store = Store(initialValues: initialValues, actionHandler: actionHandler, dependency: dependency).debug
effects = []
initFile = file
Expand Down