2021-10-26 16:14:03 -07:00
|
|
|
//
|
|
|
|
// RecoveryPhraseDisplayStoreTests.swift
|
|
|
|
// secantTests
|
|
|
|
//
|
|
|
|
// Created by Francisco Gindre on 12/8/21.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
import ComposableArchitecture
|
|
|
|
@testable import secant_testnet
|
|
|
|
|
|
|
|
class RecoveryPhraseDisplayReducerTests: XCTestCase {
|
|
|
|
func testCopyToBuffer() {
|
|
|
|
let store = TestStore(
|
2022-11-01 09:36:37 -07:00
|
|
|
initialState: RecoveryPhraseDisplayStore.test,
|
|
|
|
reducer: RecoveryPhraseDisplay()
|
2021-10-26 16:14:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
store.send(.copyToBufferPressed) {
|
2021-12-13 12:50:04 -08:00
|
|
|
$0.phrase = .placeholder
|
2021-10-26 16:14:03 -07:00
|
|
|
$0.showCopyToBufferAlert = true
|
|
|
|
}
|
|
|
|
|
|
|
|
XCTAssertEqual(
|
2022-11-01 09:36:37 -07:00
|
|
|
store.dependencies.pasteboard.getString(),
|
2021-12-13 12:50:04 -08:00
|
|
|
RecoveryPhrase.placeholder.toString()
|
2021-10-26 16:14:03 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testNewPhrase() {
|
|
|
|
let store = TestStore(
|
2022-11-01 09:36:37 -07:00
|
|
|
initialState: RecoveryPhraseDisplayStore.empty,
|
|
|
|
reducer: RecoveryPhraseDisplay()
|
2021-10-26 16:14:03 -07:00
|
|
|
)
|
|
|
|
|
2022-08-17 00:12:15 -07:00
|
|
|
store.send(.phraseResponse(.placeholder)) {
|
2021-12-13 12:50:04 -08:00
|
|
|
$0.phrase = .placeholder
|
2021-10-26 16:14:03 -07:00
|
|
|
$0.showCopyToBufferAlert = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-01 09:36:37 -07:00
|
|
|
private extension RecoveryPhraseDisplayStore {
|
|
|
|
static let test = RecoveryPhraseDisplay.State(
|
2021-12-13 12:50:04 -08:00
|
|
|
phrase: .placeholder,
|
2021-10-26 16:14:03 -07:00
|
|
|
showCopyToBufferAlert: false
|
|
|
|
)
|
|
|
|
|
2022-11-01 09:36:37 -07:00
|
|
|
static let empty = RecoveryPhraseDisplay.State(
|
2021-10-26 16:14:03 -07:00
|
|
|
phrase: .empty,
|
|
|
|
showCopyToBufferAlert: false
|
|
|
|
)
|
|
|
|
}
|