Merge pull request #1118 from LukasKorba/1041-Implement-ClearCacheAction

- ClearCacheAction tests
This commit is contained in:
Lukas Korba 2023-05-23 08:44:05 +02:00 committed by GitHub
commit ac9724163f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,36 @@
//
// ClearCacheActionTests.swift
//
//
// Created by Lukáš Korba on 22.05.2023.
//
import XCTest
@testable import TestUtils
@testable import ZcashLightClientKit
final class ClearCacheActionTests: ZcashTestCase {
func testClearCacheActionTests_NextAction() async throws {
let compactBlockRepositoryMock = CompactBlockRepositoryMock()
compactBlockRepositoryMock.clearClosure = { }
mockContainer.mock(type: CompactBlockRepository.self, isSingleton: true) { _ in compactBlockRepositoryMock }
let clearCacheAction = ClearCacheAction(
container: mockContainer
)
do {
let nextContext = try await clearCacheAction.run(with: .init(state: .clearCache)) { _ in }
XCTAssertTrue(compactBlockRepositoryMock.clearCalled, "storage.clear() is expected to be called.")
let nextState = await nextContext.state
XCTAssertTrue(
nextState == .finished,
"nextContext after .clearCache is expected to be .finished but received \(nextState)"
)
} catch {
XCTFail("testClearCacheActionTests_NextAction is not expected to fail. \(error)")
}
}
}