diff --git a/Sources/CacheStore/Stores/CacheStore.swift b/Sources/CacheStore/Stores/CacheStore.swift index 289f4ae..2e80e66 100644 --- a/Sources/CacheStore/Stores/CacheStore.swift +++ b/Sources/CacheStore/Stores/CacheStore.swift @@ -1,5 +1,6 @@ import c import Combine +import CustomDump import SwiftUI // MARK: - @@ -233,6 +234,16 @@ extension CacheStore { return false } + if + let storeValueDictionary: [AnyHashable: Any] = storeValue as? [AnyHashable: Any], + let updateValueDictionary: [AnyHashable: Any] = updatedValue as? [AnyHashable: Any] + { + let sortedStoreDictionary = storeValueDictionary.sorted(by: { "\($0.key)" == "\($1.key)" }) + let sortedUpdatedStoreDictionary = updateValueDictionary.sorted(by: { "\($0.key)" == "\($1.key)" }) + + return diff(sortedStoreDictionary, sortedUpdatedStoreDictionary) == nil + } + return "\(updatedValue)" == "\(storeValue)" } } diff --git a/Sources/CacheStore/Stores/Store.swift b/Sources/CacheStore/Stores/Store.swift index 3454cb6..2995503 100644 --- a/Sources/CacheStore/Stores/Store.swift +++ b/Sources/CacheStore/Stores/Store.swift @@ -294,9 +294,10 @@ extension Store { ) } - let areCacheEqual = cacheStore.isCacheEqual(to: cacheStoreCopy) + let sortedExpectedCacheStore = cacheStore.cache.sorted(by: { "\($0.key)" < "\($1.key)" }) + let sortedCacheStore = cacheStoreCopy.cache.sorted(by: { "\($0.key)" < "\($1.key)" }) - if areCacheEqual { + if diff(sortedExpectedCacheStore, sortedCacheStore) == nil { if isDebugging { print("\tšŸ™… No State Change") } diff --git a/Sources/CacheStore/Stores/TestStore.swift b/Sources/CacheStore/Stores/TestStore.swift index fab9dd0..2ce380b 100644 --- a/Sources/CacheStore/Stores/TestStore.swift +++ b/Sources/CacheStore/Stores/TestStore.swift @@ -67,7 +67,10 @@ public class TestStore { return } - guard expectedCacheStore.isCacheEqual(to: store.cacheStore) else { + let sortedExpectedCacheStore = expectedCacheStore.cache.sorted(by: { "\($0.key)" < "\($1.key)" }) + let sortedCacheStore = store.cacheStore.cache.sorted(by: { "\($0.key)" < "\($1.key)" }) + + guard diff(sortedExpectedCacheStore, sortedCacheStore) == nil else { TestStoreFailure.handler( """ āŒ Expectation failed @@ -128,7 +131,7 @@ public class TestStore { return } - guard "\(action)" == "\(nextAction)" else { + guard diff(action, nextAction) == nil else { TestStoreFailure.handler("āŒ Action (\(customDump(action))) does not equal NextAction (\(customDump(nextAction)))", file, line) return }